mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-13 04:26:16 -08:00
- Added DatabaseWorkerClient to manage database operations in a worker thread. - Created database-worker-client.ts to handle requests and responses between the main process and the worker. - Introduced database-worker.types.ts for type definitions related to worker messages and operations. - Implemented database.worker.ts to execute various database operations, including CRUD operations for playlists, content, and favorites. - Added database.worker-connection.ts to manage database connections and ensure proper handling of SQLite instances. - Created tests for DatabaseWorkerClient to ensure correct request handling and error management. - Updated xtream.events.ts to allow suppression of error logging for specific requests. - Enhanced EPG parser worker to include a busy timeout for SQLite operations. - Integrated shutdown logic for the DatabaseWorkerClient in the main application lifecycle.
87 lines
2.8 KiB
TypeScript
87 lines
2.8 KiB
TypeScript
import { app, BrowserWindow } from 'electron';
|
|
import { getElectronUserDataPath } from 'database';
|
|
import fixPath from 'fix-path';
|
|
import App from './app/app';
|
|
import { initDatabase } from './app/database/connection';
|
|
import DatabaseEvents from './app/events/database.events';
|
|
import {
|
|
resetStaleDownloads,
|
|
setMainWindow as setDownloadsMainWindow,
|
|
} from './app/events/database/downloads.events';
|
|
import ElectronEvents from './app/events/electron.events';
|
|
import EpgEvents from './app/events/epg.events';
|
|
import PlayerEvents from './app/events/player.events';
|
|
import PlaylistEvents from './app/events/playlist.events';
|
|
import RemoteControlEvents from './app/events/remote-control.events';
|
|
import SettingsEvents from './app/events/settings.events';
|
|
import SharedEvents from './app/events/shared.events';
|
|
import SquirrelEvents from './app/events/squirrel.events';
|
|
import StalkerEvents from './app/events/stalker.events';
|
|
import { databaseWorkerClient } from './app/services/database-worker-client';
|
|
import XtreamEvents from './app/events/xtream.events';
|
|
|
|
app.setName('iptvnator');
|
|
|
|
const electronUserDataPath = getElectronUserDataPath();
|
|
|
|
if (electronUserDataPath) {
|
|
app.setPath('userData', electronUserDataPath);
|
|
}
|
|
|
|
export default class Main {
|
|
static initialize() {
|
|
if (SquirrelEvents.handleEvents()) {
|
|
// squirrel event handled (except first run event) and app will exit in 1000ms, so don't do anything else
|
|
app.quit();
|
|
}
|
|
}
|
|
|
|
static bootstrapApp() {
|
|
App.main(app, BrowserWindow);
|
|
}
|
|
|
|
static async bootstrapAppEvents() {
|
|
// Initialize database before other events
|
|
await initDatabase();
|
|
|
|
ElectronEvents.bootstrapElectronEvents();
|
|
PlaylistEvents.bootstrapPlaylistEvents();
|
|
SharedEvents.bootstrapSharedEvents();
|
|
PlayerEvents.bootstrapPlayerEvents();
|
|
SettingsEvents.bootstrapSettingsEvents();
|
|
StalkerEvents.bootstrapStalkerEvents();
|
|
XtreamEvents.bootstrapXtreamEvents();
|
|
DatabaseEvents.bootstrapDatabaseEvents();
|
|
EpgEvents.bootstrapEpgEvents();
|
|
RemoteControlEvents.bootstrapRemoteControlEvents();
|
|
|
|
// Set main window for downloads and reset stale downloads
|
|
if (App.mainWindow) {
|
|
setDownloadsMainWindow(App.mainWindow);
|
|
}
|
|
await resetStaleDownloads();
|
|
|
|
// initialize auto updater service
|
|
if (!App.isDevelopmentMode()) {
|
|
// UpdateEvents.initAutoUpdateService();
|
|
}
|
|
}
|
|
}
|
|
|
|
fixPath();
|
|
|
|
// handle setup events as quickly as possible
|
|
Main.initialize();
|
|
|
|
// bootstrap app
|
|
Main.bootstrapApp();
|
|
|
|
// Bootstrap app events after Electron app is ready
|
|
app.whenReady().then(async () => {
|
|
await Main.bootstrapAppEvents();
|
|
});
|
|
|
|
app.on('before-quit', () => {
|
|
void databaseWorkerClient.shutdown();
|
|
});
|