mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-11 19:46:16 -08:00
fix(xtream): offer the learned panel clock to storage on every check
Review follow-up (Codex): a transient storage failure left the clock in the store but not on the row, and the next check compared the answer with the in-memory value and never retried. The resolved timezone is now always handed to `transformPlaylistMeta`, whose row-level equality check keeps the common case a read without a write; a failed write is retried by the next account-info check. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
cd364525fa
commit
1c446cd5be
2 files changed
+30
-6
No files matched your search
@@ -174,14 +174,36 @@ describe('withPortal', () => {
|
||||
expect(storedPlaylist.serverTimezone).toBe('UTC+03:00');
|
||||
});
|
||||
|
||||
it('does not rewrite the row when it already carries the value', async () => {
|
||||
it('offers the value to storage every time but writes nothing when the row already carries it', async () => {
|
||||
storedPlaylist = { ...storedPlaylist, serverTimezone: 'UTC' };
|
||||
store.setCurrentPlaylist({ ...PLAYLIST, serverTimezone: 'UTC' });
|
||||
respondWith({ timezone: 'UTC' });
|
||||
|
||||
await store.checkPortalStatus();
|
||||
|
||||
expect(transformPlaylistMeta).not.toHaveBeenCalled();
|
||||
expect(transformPlaylistMeta).toHaveBeenCalledTimes(1);
|
||||
const [, transform] = transformPlaylistMeta.mock.calls[0];
|
||||
expect(transform(storedPlaylist)).toBeNull();
|
||||
});
|
||||
|
||||
it('retries the write on the next check after a transient storage failure', async () => {
|
||||
transformPlaylistMeta.mockImplementationOnce(() => {
|
||||
throw new Error('storage unavailable');
|
||||
});
|
||||
respondWith({ timezone: 'Europe/London' });
|
||||
|
||||
await store.checkPortalStatus();
|
||||
expect(store.currentPlaylist()?.serverTimezone).toBe(
|
||||
'Europe/London'
|
||||
);
|
||||
expect(storedPlaylist.serverTimezone).toBeUndefined();
|
||||
|
||||
// The store already carries the clock, so only the row-level
|
||||
// check may decide that the row still lacks it.
|
||||
await store.checkPortalStatus();
|
||||
|
||||
expect(transformPlaylistMeta).toHaveBeenCalledTimes(2);
|
||||
expect(storedPlaylist.serverTimezone).toBe('Europe/London');
|
||||
});
|
||||
|
||||
it('keeps the previously known timezone when the response carries no usable clock', async () => {
|
||||
|
||||
@@ -193,10 +193,12 @@ export function withPortal() {
|
||||
},
|
||||
});
|
||||
}
|
||||
if (
|
||||
serverTimezone &&
|
||||
serverTimezone !== playlist.serverTimezone
|
||||
) {
|
||||
// Always offered to storage, never gated on the
|
||||
// in-memory value: after a transient write failure
|
||||
// the store already carries the clock, and only the
|
||||
// row-level check inside the transform knows whether
|
||||
// the row does too.
|
||||
if (serverTimezone) {
|
||||
await rememberServerTimezone(
|
||||
playlist.id,
|
||||
credentials,
|
||||
|
||||
Reference in new issue
Block a user