Skip to content

Commit 4d6434b

Browse files
committed
Added Notifications + Bug Fixes
Fixed race condition when initializing settings Added notifications and their overlay Updated app initialization Allows quick-navigation to the apps page
1 parent 1c8c198 commit 4d6434b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1409
-266
lines changed

DeskThingServer/electron.vite.config.1751480604345.mjs

Lines changed: 0 additions & 72 deletions
This file was deleted.

DeskThingServer/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

DeskThingServer/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"zustand": "^5.0.0-rc.2"
5454
},
5555
"devDependencies": {
56-
"@deskthing/types": "^0.11.16",
56+
"@deskthing/types": "^0.11.18",
5757
"@electron-toolkit/eslint-config-prettier": "^3.0.0",
5858
"@electron-toolkit/eslint-config-ts": "^3.0.0",
5959
"@electron-toolkit/preload": "^3.0.1",

DeskThingServer/src/main/services/files/releaseFileService.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
import { readFromFile, writeToFile } from './fileService'
88
import { join } from 'node:path'
99
import logger from '@server/utils/logger'
10-
import { handleReleaseJSONFileMigration } from '../releases/migrationUtils'
10+
import { assertReleaseFileMigration } from '../releases/migrationUtils'
1111

1212
export const saveAppReleaseData = async (appReleaseFile: AppReleaseFile): Promise<void> => {
1313
try {
@@ -47,7 +47,7 @@ export const readAppReleaseData = async (): Promise<AppReleaseFile01111 | undefi
4747

4848
if (!appReleaseFile) throw new Error('Invalid app release file (does not exist)')
4949

50-
return handleReleaseJSONFileMigration(appReleaseFile)
50+
return assertReleaseFileMigration(appReleaseFile)
5151
} catch (error) {
5252
logger.error(`Failed to read app release files`, {
5353
error: error as Error,
@@ -66,7 +66,7 @@ export const readClientReleaseData = async (): Promise<ClientReleaseFile01111 |
6666

6767
if (!clientReleaseFile) throw new Error('Invalid client release file (does not exist)')
6868

69-
return handleReleaseJSONFileMigration(clientReleaseFile)
69+
return assertReleaseFileMigration(clientReleaseFile)
7070
} catch (error) {
7171
logger.error(`Failed to read client release files`, {
7272
error: error as Error,

DeskThingServer/src/main/services/initialization/AfterStartupTasks.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,10 @@ export const afterStartTasks = async (): Promise<void> => {
2727
const updateStore = await storeProvider.getStore('updateStore')
2828
await updateStore.checkForUpdates()
2929

30+
// check for server-notifications
31+
debug('Checking for server notifications...')
32+
const notificationStore = await storeProvider.getStore('notificationStore')
33+
await notificationStore.checkForNotifications()
34+
3035
log('Finished running post-run tasks')
3136
}

DeskThingServer/src/main/services/ipc/utilityIpc.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,27 @@ export const utilityHandler: {
6262
return
6363
}
6464
},
65+
[IPC_UTILITY_TYPES.FLAG]: async (data) => {
66+
const settingsStore = await storeProvider.getStore('settingsStore')
67+
switch (data.request) {
68+
case 'get':
69+
return await settingsStore.getFlag(data.payload)
70+
case 'set':
71+
return await settingsStore.setFlag(data.payload.flagId, data.payload.flagState)
72+
case 'toggle':
73+
return await settingsStore.toggleFlag(data.payload)
74+
}
75+
},
76+
[IPC_UTILITY_TYPES.NOTIFICATION]: async (data) => {
77+
const notificationStore = await storeProvider.getStore('notificationStore')
78+
79+
switch (data.request) {
80+
case 'get':
81+
return await notificationStore.getNotificationList()
82+
case 'acknowledge':
83+
return await notificationStore.acknowledgeNotification(data.payload)
84+
}
85+
},
6586
[IPC_UTILITY_TYPES.SUPPORTERS]: async (data) => {
6687
const supporterStore = await storeProvider.getStore('supporterStore')
6788
switch (data.request) {

DeskThingServer/src/main/services/releases/migrationUtils.ts

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ import { unlink, writeFile } from 'node:fs/promises'
5151
/**
5252
* Handles the migration of any old file to the current file
5353
*/
54-
export async function handleReleaseJSONFileMigration(
54+
export async function assertReleaseFileMigration(
5555
releaseFile: AppReleaseFile
5656
): Promise<AppReleaseFile01111>
57-
export async function handleReleaseJSONFileMigration(
57+
export async function assertReleaseFileMigration(
5858
releaseFile: ClientReleaseFile
5959
): Promise<ClientReleaseFile01111>
60-
export async function handleReleaseJSONFileMigration(
60+
export async function assertReleaseFileMigration(
6161
releaseFile: AppReleaseFile | ClientReleaseFile
6262
): Promise<AppReleaseFile01111 | ClientReleaseFile01111> {
6363
// Migrating from older release files is not supported.
@@ -69,18 +69,18 @@ export async function handleReleaseJSONFileMigration(
6969
if (releaseFile.version == '0.11.8') {
7070
// Type narrowing based on the 'type' property
7171
if (releaseFile.type === 'app') {
72-
return handleReleaseJSONFileMigration0118(releaseFile)
72+
return assertReleaseFileMigration0118(releaseFile)
7373
} else {
74-
return handleReleaseJSONFileMigration0118(releaseFile)
74+
return assertReleaseFileMigration0118(releaseFile)
7575
}
7676
}
7777

7878
if (releaseFile.version == '0.10.0') {
7979
// Type narrowing based on the 'references' existence
8080
if ('references' in releaseFile) {
81-
return handleReleaseJSONFileMigration0108(releaseFile)
81+
return assertReleaseFileMigration0108(releaseFile)
8282
} else {
83-
return handleReleaseJSONFileMigration0108(releaseFile)
83+
return assertReleaseFileMigration0108(releaseFile)
8484
}
8585
}
8686

@@ -89,17 +89,17 @@ export async function handleReleaseJSONFileMigration(
8989
}
9090

9191
/**
92-
* Handles the migration of any old file to the current file
92+
* Handles the migration of old v0.11.8 release file versions to the 0.11.11 format
9393
* @param releaseFile - The release file to migrate
9494
* @returns The migrated release file
9595
*/
96-
export async function handleReleaseJSONFileMigration0118(
96+
export async function assertReleaseFileMigration0118(
9797
releaseFile: AppReleaseFile0118
9898
): Promise<AppReleaseFile01111>
99-
export async function handleReleaseJSONFileMigration0118(
99+
export async function assertReleaseFileMigration0118(
100100
releaseFile: ClientReleaseFile0118
101101
): Promise<ClientReleaseFile01111>
102-
export async function handleReleaseJSONFileMigration0118(
102+
export async function assertReleaseFileMigration0118(
103103
releaseFile: AppReleaseFile0118 | ClientReleaseFile0118
104104
): Promise<AppReleaseFile01111 | ClientReleaseFile01111> {
105105
// version is outdated (oops)
@@ -128,13 +128,17 @@ export async function handleReleaseJSONFileMigration0118(
128128
}
129129
}
130130

131-
export async function handleReleaseJSONFileMigration0108(
131+
/**
132+
* Handles the migration of any old release file to the 01111 file format
133+
* @param releaseFile
134+
*/
135+
export async function assertReleaseFileMigration0108(
132136
releaseFile: ClientReleaseFile0108
133137
): Promise<ClientReleaseFile01111>
134-
export async function handleReleaseJSONFileMigration0108(
138+
export async function assertReleaseFileMigration0108(
135139
releaseFile: AppReleaseFile0108
136140
): Promise<AppReleaseFile01111>
137-
export async function handleReleaseJSONFileMigration0108(
141+
export async function assertReleaseFileMigration0108(
138142
releaseFile: AppReleaseFile0108 | ClientReleaseFile0108
139143
): Promise<AppReleaseFile01111 | ClientReleaseFile01111> {
140144
// version is outdated (oops)

0 commit comments

Comments
 (0)