diff --git a/apps/electron-backend/src/app/api/main.preload.ts b/apps/electron-backend/src/app/api/main.preload.ts index e17de49d7..35058aa15 100644 --- a/apps/electron-backend/src/app/api/main.preload.ts +++ b/apps/electron-backend/src/app/api/main.preload.ts @@ -8,8 +8,10 @@ contextBridge.exposeInMainWorld('electron', { updatePlaylistFromFilePath: (filePath: string, title: string) => ipcRenderer.invoke('update-playlist-from-file-path', filePath, title), openPlaylistFromFile: () => ipcRenderer.invoke('open-playlist-from-file'), - saveFileDialog: (defaultPath: string, filters?: { name: string; extensions: string[] }[]) => - ipcRenderer.invoke('save-file-dialog', defaultPath, filters), + saveFileDialog: ( + defaultPath: string, + filters?: { name: string; extensions: string[] }[] + ) => ipcRenderer.invoke('save-file-dialog', defaultPath, filters), writeFile: (filePath: string, content: string) => ipcRenderer.invoke('write-file', filePath, content), setUserAgent: (userAgent: string, referer?: string) => diff --git a/apps/electron-backend/src/app/app.ts b/apps/electron-backend/src/app/app.ts index 1e9bdd976..6bd03b797 100644 --- a/apps/electron-backend/src/app/app.ts +++ b/apps/electron-backend/src/app/app.ts @@ -78,6 +78,8 @@ export default class App { preload: join(__dirname, 'main.preload.js'), }, ...savedWindowBounds, + minHeight: 600, + minWidth: 900, }); App.mainWindow.setMenu(null); if (!savedWindowBounds) { diff --git a/apps/electron-backend/src/app/events/player.events.ts b/apps/electron-backend/src/app/events/player.events.ts index 7f1f221b0..05439d8a6 100644 --- a/apps/electron-backend/src/app/events/player.events.ts +++ b/apps/electron-backend/src/app/events/player.events.ts @@ -90,7 +90,10 @@ ipcMain.handle( ); return; } catch (err) { - console.error('Failed to send command to existing MPV:', err); + console.error( + 'Failed to send command to existing MPV:', + err + ); // If it fails, clear the reference and create a new one mpvProcess = null; mpvSocketPath = null; diff --git a/apps/electron-backend/src/app/events/xtream.events.ts b/apps/electron-backend/src/app/events/xtream.events.ts index feac61751..f53e366f4 100644 --- a/apps/electron-backend/src/app/events/xtream.events.ts +++ b/apps/electron-backend/src/app/events/xtream.events.ts @@ -5,7 +5,6 @@ import axios, { AxiosRequestConfig } from 'axios'; import { ipcMain } from 'electron'; -import { XTREAM_REQUEST } from 'shared-interfaces'; export default class XtreamEvents { static bootstrapXtreamEvents(): Electron.IpcMain { @@ -17,7 +16,7 @@ export default class XtreamEvents { * Handle Xtream Codes API requests */ ipcMain.handle( - XTREAM_REQUEST, + 'XTREAM_REQUEST', async ( event, payload: { @@ -77,7 +76,11 @@ ipcMain.handle( status: error.response?.status || 500, }; throw errorResponse; - } else if (error && typeof error === 'object' && 'message' in error) { + } else if ( + error && + typeof error === 'object' && + 'message' in error + ) { throw error; } else { throw { diff --git a/apps/web/src/app/app.component.ts b/apps/web/src/app/app.component.ts index 7925c5f17..07472a9c3 100644 --- a/apps/web/src/app/app.component.ts +++ b/apps/web/src/app/app.component.ts @@ -1,6 +1,5 @@ -import { Component, inject, OnDestroy, OnInit } from '@angular/core'; +import { Component, inject, OnInit } from '@angular/core'; import { MatDialog } from '@angular/material/dialog'; -import { MatSnackBar } from '@angular/material/snack-bar'; import { Router, RouterOutlet } from '@angular/router'; import { Store } from '@ngrx/store'; import { TranslateService } from '@ngx-translate/core'; @@ -8,15 +7,11 @@ import { TranslateService } from '@ngx-translate/core'; import * as PlaylistActions from 'm3u-state'; import { DataService, EpgService } from 'services'; import { - ERROR, - IpcCommand, Language, OPEN_FILE, Settings, STORE_KEY, Theme, - VIEW_ADD_PLAYLIST, - VIEW_SETTINGS, } from 'shared-interfaces'; import { SettingsService } from './services/settings.service'; import { RecentlyViewedComponent } from './xtream-tauri/recently-viewed/recently-viewed.component'; @@ -27,30 +22,24 @@ import { SearchResultsComponent } from './xtream-tauri/search-results/search-res templateUrl: './app.component.html', imports: [RouterOutlet], }) -export class AppComponent implements OnInit, OnDestroy { +export class AppComponent implements OnInit { private dataService = inject(DataService); private dialog = inject(MatDialog); private epgService = inject(EpgService); private router = inject(Router); private store = inject(Store); - private snackBar = inject(MatSnackBar); private translate = inject(TranslateService); private settingsService = inject(SettingsService); /** List of ipc commands with function mapping */ - private readonly commandsList = [ + /* private readonly commandsList = [ new IpcCommand(VIEW_ADD_PLAYLIST, () => this.navigateToRoute('/')), new IpcCommand(VIEW_SETTINGS, () => this.navigateToRoute('/settings')), - new IpcCommand(ERROR, (response: { message: string; status: number }) => - this.showErrorAsNotification(response) - ), - ]; + ]; */ /** Default language as fallback */ private readonly DEFAULT_LANG = Language.ENGLISH; - private listeners = []; - constructor() { if ( ((this.dataService.isElectron && @@ -90,24 +79,7 @@ export class AppComponent implements OnInit, OnDestroy { this.store.dispatch(PlaylistActions.loadPlaylists()); this.translate.setDefaultLang(this.DEFAULT_LANG); - this.setRendererListeners(); this.initSettings(); - /* this.handleWhatsNewDialog(); */ - } - - /** - * Initializes all necessary listeners for the events from the renderer process - */ - setRendererListeners(): void { - this.commandsList.forEach((command) => { - const cb = (response) => { - if (response.data.type === command.id) { - command.callback(response.data); - } - }; - this.dataService.listenOn(command.id, cb); - this.listeners.push(cb); - }); } /** @@ -134,6 +106,8 @@ export class AppComponent implements OnInit, OnDestroy { this.epgService.fetchEpg(settings.epgUrl); } + // TODO: trigger auto-refresh mechanism for playlists + if (settings.theme) { this.settingsService.changeTheme(settings.theme); } else { @@ -160,21 +134,6 @@ export class AppComponent implements OnInit, OnDestroy { } } - /** - * Checks the actual version of the application and shows the "what is new" dialog if the updated version was detected - */ - /* handleWhatsNewDialog(): void { - const actualVersion = this.dataService.getAppVersion(); - this.settingsService - .getValueFromLocalStorage(STORE_KEY.Version) - .subscribe(() => { - this.settingsService.setValueToLocalStorage( - STORE_KEY.Version, - actualVersion - ); - }); - } */ - /** * Navigate to the specified route * @param route route to navigate to @@ -183,16 +142,6 @@ export class AppComponent implements OnInit, OnDestroy { this.router.navigateByUrl(route); } - showErrorAsNotification(response: { message: string; status: number }) { - this.snackBar.open( - `Error: ${response?.message ?? 'Something went wrong'} (Status: ${ - response?.status ?? 0 - })`, - null, - { duration: 4000 } - ); - } - openGlobalSearch(): void { this.dialog.open(SearchResultsComponent, { width: '100%', @@ -214,19 +163,4 @@ export class AppComponent implements OnInit, OnDestroy { disableClose: false, }); } - - /** - * Removes all ipc command listeners on component destroy - */ - ngOnDestroy(): void { - if (this.dataService.isElectron) { - this.commandsList.forEach((command) => - this.dataService.removeAllListeners(command.id) - ); - } else { - this.listeners.forEach((listener) => - window.removeEventListener('message', listener) - ); - } - } } diff --git a/apps/web/src/app/home/home.component.html b/apps/web/src/app/home/home.component.html index 8d2c48dbe..a7574a9b1 100644 --- a/apps/web/src/app/home/home.component.html +++ b/apps/web/src/app/home/home.component.html @@ -1,10 +1,5 @@ -