mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-15 13:46:16 -08:00
fix(pwa): restore xtream rail and vod navigation
This commit is contained in:
1 parent
89df1ada0a
commit
6829c667bd
7 files changed
+335
-38
No files matched your search
@@ -0,0 +1,47 @@
|
||||
import { DatabaseService } from './database-electron.service';
|
||||
|
||||
describe('DatabaseService browser guards', () => {
|
||||
const originalElectron = window.electron;
|
||||
let service: DatabaseService;
|
||||
let consoleErrorSpy: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
Object.defineProperty(window, 'electron', {
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: undefined,
|
||||
});
|
||||
consoleErrorSpy = jest
|
||||
.spyOn(console, 'error')
|
||||
.mockImplementation(() => undefined);
|
||||
|
||||
service = new DatabaseService();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
consoleErrorSpy.mockRestore();
|
||||
Object.defineProperty(window, 'electron', {
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: originalElectron,
|
||||
});
|
||||
});
|
||||
|
||||
it('treats app state persistence as unavailable without the Electron bridge', async () => {
|
||||
await expect(service.getAppState('xtream-key')).resolves.toBeNull();
|
||||
await expect(
|
||||
service.setAppState('xtream-key', 'completed')
|
||||
).resolves.toBe(false);
|
||||
await expect(
|
||||
service.getXtreamImportStatus('playlist-1', 'movie')
|
||||
).resolves.toBe('idle');
|
||||
await expect(
|
||||
service.setXtreamImportStatus('playlist-1', 'movie', 'completed')
|
||||
).resolves.toBe(false);
|
||||
await expect(
|
||||
service.getContentByXtreamId(20229, 'playlist-1', 'movie')
|
||||
).resolves.toBeNull();
|
||||
|
||||
expect(consoleErrorSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
@@ -157,11 +157,11 @@ export class DatabaseService {
|
||||
}
|
||||
|
||||
supportsDbOperationEvents(): boolean {
|
||||
return typeof window.electron.onDbOperationEvent === 'function';
|
||||
return typeof window.electron?.onDbOperationEvent === 'function';
|
||||
}
|
||||
|
||||
supportsDbOperationCancellation(): boolean {
|
||||
return typeof window.electron.dbCancelOperation === 'function';
|
||||
return typeof window.electron?.dbCancelOperation === 'function';
|
||||
}
|
||||
|
||||
async cancelOperation(operationId: string): Promise<boolean> {
|
||||
@@ -496,6 +496,10 @@ export class DatabaseService {
|
||||
playlistId: string,
|
||||
type: 'live' | 'movie' | 'series'
|
||||
): Promise<boolean> {
|
||||
if (typeof window.electron?.dbClearXtreamImportCache !== 'function') {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
await window.electron.dbClearXtreamImportCache(playlistId, type);
|
||||
return true;
|
||||
@@ -506,6 +510,10 @@ export class DatabaseService {
|
||||
}
|
||||
|
||||
async getAppState(key: string): Promise<string | null> {
|
||||
if (typeof window.electron?.dbGetAppState !== 'function') {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
return await window.electron.dbGetAppState(key);
|
||||
} catch (error) {
|
||||
@@ -515,6 +523,10 @@ export class DatabaseService {
|
||||
}
|
||||
|
||||
async setAppState(key: string, value: string): Promise<boolean> {
|
||||
if (typeof window.electron?.dbSetAppState !== 'function') {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
await window.electron.dbSetAppState(key, value);
|
||||
return true;
|
||||
@@ -861,6 +873,10 @@ export class DatabaseService {
|
||||
playlistId: string,
|
||||
contentType?: 'live' | 'movie' | 'series'
|
||||
): Promise<XtreamContent | null> {
|
||||
if (typeof window.electron?.dbGetContentByXtreamId !== 'function') {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
return await window.electron.dbGetContentByXtreamId(
|
||||
xtreamId,
|
||||
|
||||
Reference in new issue
Block a user