mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-11 19:46:16 -08:00
fix(playlist): preserve auto-refresh on manual refresh
This commit is contained in:
1 parent
2d5c4fa4f9
commit
a5ea92682b
4 files changed
+85
-2
No files matched your search
@@ -130,4 +130,38 @@ describe('playlistReducers', () => {
|
||||
nextState.playlists.entities['playlist-1']?.hiddenGroupTitles
|
||||
).toEqual(['Radio-de']);
|
||||
});
|
||||
|
||||
it('keeps autoRefresh enabled on playlist refresh when the parser payload defaults it to false', () => {
|
||||
const existingPlaylist: PlaylistMeta = {
|
||||
_id: 'playlist-1',
|
||||
autoRefresh: true,
|
||||
count: 1,
|
||||
importDate: '2026-03-28T00:00:00.000Z',
|
||||
title: 'Playlist One',
|
||||
} as PlaylistMeta;
|
||||
const state = {
|
||||
...initialState,
|
||||
playlists: playlistsAdapter.addOne(existingPlaylist, {
|
||||
...initialState.playlists,
|
||||
selectedId: 'playlist-1',
|
||||
}),
|
||||
};
|
||||
|
||||
const nextState = reducer(
|
||||
state,
|
||||
PlaylistActions.updatePlaylist({
|
||||
playlist: {
|
||||
autoRefresh: false,
|
||||
playlist: {
|
||||
items: [],
|
||||
},
|
||||
} as Playlist,
|
||||
playlistId: 'playlist-1',
|
||||
})
|
||||
);
|
||||
|
||||
expect(
|
||||
nextState.playlists.entities['playlist-1']?.autoRefresh
|
||||
).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -33,6 +33,7 @@ export const playlistReducers = [
|
||||
on(PlaylistActions.updatePlaylist, (state, action): PlaylistState => {
|
||||
const isActivePlaylist =
|
||||
state.playlists.selectedId === action.playlistId;
|
||||
const currentPlaylist = state.playlists.entities[action.playlistId];
|
||||
return {
|
||||
...state,
|
||||
channels: isActivePlaylist
|
||||
@@ -49,8 +50,10 @@ export const playlistReducers = [
|
||||
count: action.playlist.playlist.items.length,
|
||||
userAgent: action.playlist.userAgent,
|
||||
favorites:
|
||||
state.playlists.entities[action.playlistId]
|
||||
?.favorites ?? [],
|
||||
currentPlaylist?.favorites ?? [],
|
||||
autoRefresh:
|
||||
currentPlaylist?.autoRefresh ??
|
||||
action.playlist.autoRefresh,
|
||||
},
|
||||
},
|
||||
state.playlists
|
||||
|
||||
@@ -411,4 +411,47 @@ describe('PlaylistsService', () => {
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
it('keeps autoRefresh enabled when refreshing a playlist payload with the parser default disabled', async () => {
|
||||
const existingPlaylist: Playlist = {
|
||||
_id: 'playlist-3',
|
||||
title: 'Playlist Three',
|
||||
count: 1,
|
||||
importDate: new Date('2026-04-12T00:00:00.000Z').toISOString(),
|
||||
lastUsage: new Date('2026-04-12T00:00:00.000Z').toISOString(),
|
||||
autoRefresh: true,
|
||||
playlist: {
|
||||
items: [{ id: 'channel-1' }],
|
||||
},
|
||||
} as Playlist;
|
||||
const dbService = {
|
||||
getAll: jest.fn(() => of([])),
|
||||
getByID: jest.fn(() => of(existingPlaylist)),
|
||||
update: jest.fn((_storeName: string, playlist: Playlist) =>
|
||||
of(playlist)
|
||||
),
|
||||
};
|
||||
testWindow.electron = undefined;
|
||||
|
||||
const service = createService(dbService);
|
||||
|
||||
await firstValueFrom(
|
||||
service.updatePlaylist('playlist-3', {
|
||||
_id: 'playlist-3',
|
||||
autoRefresh: false,
|
||||
playlist: {
|
||||
items: [],
|
||||
},
|
||||
} as Playlist)
|
||||
);
|
||||
|
||||
expect(dbService.update).toHaveBeenCalledWith(
|
||||
DbStores.Playlists,
|
||||
expect.objectContaining({
|
||||
_id: 'playlist-3',
|
||||
autoRefresh: true,
|
||||
count: 0,
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -436,6 +436,9 @@ export class PlaylistsService {
|
||||
updateDate: Date.now(),
|
||||
updateState: PlaylistUpdateState.UPDATED,
|
||||
favorites: currentPlaylist.favorites,
|
||||
autoRefresh:
|
||||
currentPlaylist.autoRefresh ??
|
||||
updatedPlaylist.autoRefresh,
|
||||
};
|
||||
|
||||
if (this.isElectronStorageAvailable) {
|
||||
|
||||
Reference in new issue
Block a user