diff --git a/DeskThingServer/src/main/handlers/apps/appState.ts b/DeskThingServer/src/main/handlers/apps/appState.ts index 6f7372e0..2a12b216 100644 --- a/DeskThingServer/src/main/handlers/apps/appState.ts +++ b/DeskThingServer/src/main/handlers/apps/appState.ts @@ -57,6 +57,7 @@ export class AppHandler { const { setAppsData } = await import('../configHandler') const apps = this.getAllBase() await setAppsData(apps) + this.notify() } private async saveAppToFile(name: string): Promise { diff --git a/DeskThingServer/src/main/index.ts b/DeskThingServer/src/main/index.ts index b9be22af..3b9cbb70 100644 --- a/DeskThingServer/src/main/index.ts +++ b/DeskThingServer/src/main/index.ts @@ -40,6 +40,7 @@ const IPC_CHANNELS = { RUN_DEVICE_COMMAND: 'run-device-command', GET_SETTINGS: 'get-settings', SAVE_SETTINGS: 'save-settings', + SET_ORDER: 'set-app-order', GET_APPS: 'get-apps', GET_APP_DATA: 'get-app-data', GET_GITHUB: 'fetch-github-releases', @@ -319,6 +320,10 @@ async function setupIpcHandlers(): Promise { event.reply('logging', { status: true, data: 'Finished', final: true }) event.reply('app-data', { status: true, data: data, final: true }) }) + ipcMain.on(IPC_CHANNELS.SET_ORDER, (event, order) => { + appHandler.reorder(order) + event.reply('logging', { status: true, data: 'Finished', final: true }) + }) ipcMain.on(IPC_CHANNELS.STOP_APP, async (event, appName: string) => { event.reply('logging', { status: true, data: 'Stopping App', final: false }) await appHandler.stop(appName) diff --git a/DeskThingServer/src/renderer/src/store/appStore.ts b/DeskThingServer/src/renderer/src/store/appStore.ts index 09c9edd9..cdf01e0d 100644 --- a/DeskThingServer/src/renderer/src/store/appStore.ts +++ b/DeskThingServer/src/renderer/src/store/appStore.ts @@ -66,18 +66,8 @@ class AppStore extends EventEmitter { } public setOrder(order: string[]): void { this.order = order - console.log('Order set to:', this.order) - this.organizeAppsList() - } - private organizeAppsList(): void { - console.log('Organizing apps list...') - if (this.appsList) { - const organizedApps = this.order - .map((appName) => this.appsList.find((app) => app.name === appName)) - .filter((app) => app !== undefined) as App[] - this.appsList = organizedApps - this.emit('update', this.appsList) - } + window.electron.ipcRenderer.send('set-app-order', this.order) + this.requestApps() } public removeAppFromList(appName: string): void {