Skip to content

Commit

Permalink
Final Touches to app switching
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsRiprod committed Sep 19, 2024
1 parent 33d089d commit 9fd4c3b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
1 change: 1 addition & 0 deletions DeskThingServer/src/main/handlers/apps/appState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
Expand Down
5 changes: 5 additions & 0 deletions DeskThingServer/src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -319,6 +320,10 @@ async function setupIpcHandlers(): Promise<void> {
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)
Expand Down
14 changes: 2 additions & 12 deletions DeskThingServer/src/renderer/src/store/appStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,8 @@ class AppStore extends EventEmitter<appStoreEvents> {
}
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 {
Expand Down

0 comments on commit 9fd4c3b

Please sign in to comment.