mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-08 09:01:03 -08:00
fix(dashboard): address rail review feedback
This commit is contained in:
1 parent
b6c5367d63
commit
dbc90bed06
4 files changed
+22
-14
No files matched your search
@@ -23,6 +23,9 @@ function createGlobalFavoritesDbMock(rows: unknown[]) {
|
||||
innerJoin: jest.fn(),
|
||||
limit: jest.fn(),
|
||||
orderBy: jest.fn(),
|
||||
then: jest.fn((resolve, reject) =>
|
||||
Promise.resolve(rows).then(resolve, reject)
|
||||
),
|
||||
where: whereMock,
|
||||
};
|
||||
query.from.mockReturnValue(query);
|
||||
@@ -48,7 +51,7 @@ describe('favorites.operations', () => {
|
||||
});
|
||||
|
||||
it('filters live global favorites after scanning the small favorites set', async () => {
|
||||
const { db } = createGlobalFavoritesDbMock([
|
||||
const { db, query } = createGlobalFavoritesDbMock([
|
||||
{
|
||||
id: 1,
|
||||
title: 'Saved Movie',
|
||||
@@ -64,6 +67,7 @@ describe('favorites.operations', () => {
|
||||
const result = await getGlobalFavorites(db);
|
||||
|
||||
expect(whereMock).not.toHaveBeenCalled();
|
||||
expect(query.limit).not.toHaveBeenCalled();
|
||||
expect(result).toEqual([
|
||||
expect.objectContaining({
|
||||
id: 2,
|
||||
|
||||
@@ -10,7 +10,6 @@ import {
|
||||
import { persistContentBackdropIfMissing } from './content-backdrop.operations';
|
||||
|
||||
const DEFAULT_BATCH_SIZE = 100;
|
||||
const GLOBAL_LIVE_FAVORITES_SCAN_LIMIT = 2000;
|
||||
|
||||
export async function addFavorite(
|
||||
db: AppDatabase,
|
||||
@@ -92,7 +91,7 @@ export async function getFavorites(db: AppDatabase, playlistId: string) {
|
||||
export async function getGlobalFavorites(db: AppDatabase) {
|
||||
const favorites = await selectGlobalFavoriteRows(db, {
|
||||
includeBackdrop: false,
|
||||
}).limit(GLOBAL_LIVE_FAVORITES_SCAN_LIMIT);
|
||||
});
|
||||
|
||||
return favorites.filter((favorite) => favorite.type === 'live').slice(0, 300);
|
||||
}
|
||||
|
||||
@@ -449,6 +449,8 @@ describe('DashboardDataService', () => {
|
||||
expect.objectContaining({ title: 'Channel Two' }),
|
||||
])
|
||||
);
|
||||
expect(service.globalFavoritesLoaded()).toBe(true);
|
||||
expect(service.globalFavoritesLoading()).toBe(false);
|
||||
});
|
||||
|
||||
it('keeps the earliest matching M3U favorite id when channel id and URL both match', async () => {
|
||||
|
||||
@@ -542,6 +542,12 @@ export class DashboardDataService {
|
||||
const m3uReload = this.reloadPlaylistBackedGlobalFavorites();
|
||||
|
||||
await Promise.all([xtreamReload, m3uReload]);
|
||||
if (
|
||||
this.playlistsLoaded() &&
|
||||
!this.playlistBackedGlobalFavoritesLoadedState()
|
||||
) {
|
||||
await this.reloadPlaylistBackedGlobalFavorites();
|
||||
}
|
||||
this.finishInitialGlobalFavoritesLoadIfReady();
|
||||
this.favoritesAutoRefreshEnabled.set(true);
|
||||
}
|
||||
@@ -1212,17 +1218,14 @@ export class DashboardDataService {
|
||||
const fallbackTimestamp =
|
||||
this.getM3uFavoriteTimestamp(playlistMeta) ??
|
||||
new Date(0).toISOString();
|
||||
const items = resolvedChannels
|
||||
.slice()
|
||||
.sort((a, b) => a.favoriteIndex - b.favoriteIndex)
|
||||
.map((favorite) =>
|
||||
this.createM3uFavoriteItem(
|
||||
playlistMeta,
|
||||
favorite.favoriteId,
|
||||
favorite.channel,
|
||||
fallbackTimestamp
|
||||
)
|
||||
);
|
||||
const items = resolvedChannels.slice().map((favorite) =>
|
||||
this.createM3uFavoriteItem(
|
||||
playlistMeta,
|
||||
favorite.favoriteId,
|
||||
favorite.channel,
|
||||
fallbackTimestamp
|
||||
)
|
||||
);
|
||||
|
||||
this.m3uFavoritesCache.set(playlistMeta._id, {
|
||||
fingerprint,
|
||||
|
||||
Reference in new issue
Block a user