diff --git a/DeskThingServer/package-lock.json b/DeskThingServer/package-lock.json index 613def58..f8be15cb 100644 --- a/DeskThingServer/package-lock.json +++ b/DeskThingServer/package-lock.json @@ -1,12 +1,12 @@ { "name": "deskthing", - "version": "0.8.0", + "version": "0.8.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "deskthing", - "version": "0.8.0", + "version": "0.8.1", "hasInstallScript": true, "dependencies": { "@electron-toolkit/preload": "^3.0.0", diff --git a/DeskThingServer/package.json b/DeskThingServer/package.json index a9adaa8b..4a9d67d8 100644 --- a/DeskThingServer/package.json +++ b/DeskThingServer/package.json @@ -1,6 +1,6 @@ { "name": "deskthing", - "version": "0.8.0", + "version": "0.8.1", "description": "A DeskThing server UI to interface with the DeskThing car thing app", "main": "./out/main/index.js", "author": "Riprod", diff --git a/DeskThingServer/resources/icon.png b/DeskThingServer/resources/icon.png new file mode 100644 index 00000000..997b8e56 Binary files /dev/null and b/DeskThingServer/resources/icon.png differ diff --git a/DeskThingServer/src/main/handlers/adbHandler.ts b/DeskThingServer/src/main/handlers/adbHandler.ts index 9cea6656..2f1f10f7 100644 --- a/DeskThingServer/src/main/handlers/adbHandler.ts +++ b/DeskThingServer/src/main/handlers/adbHandler.ts @@ -25,10 +25,12 @@ const splitArgs = (str: string): string[] => { } export const handleAdbCommands = async (command: string, event?): Promise => { - const useGlobalADB = (await settingsStore.getSettings()).payload.globalADB || true + const settings = await settingsStore.getSettings() + const useGlobalADB = settings.payload.globalADB === true + dataListener.emit(MESSAGE_TYPES.LOGGING, useGlobalADB ? 'Using Global ADB' : 'Using Local ADB') return new Promise((resolve, reject) => { execFile( - useGlobalADB ? adbPath : 'adb', + useGlobalADB ? 'adb' : adbPath, splitArgs(command), { cwd: execPath }, (error, stdout, stderr) => { diff --git a/DeskThingServer/src/main/handlers/appHandler.ts b/DeskThingServer/src/main/handlers/appHandler.ts index 8ffeacf8..473812b3 100644 --- a/DeskThingServer/src/main/handlers/appHandler.ts +++ b/DeskThingServer/src/main/handlers/appHandler.ts @@ -540,16 +540,19 @@ async function purgeApp(appName: string): Promise { if (appInstance && typeof appInstance.purge === 'function') { await appInstance.purge() } - runningApps.delete(appName) + const isDeleted = runningApps.delete(appName) console.log('stopped ', appName) + dataListener.emit( + MESSAGE_TYPES.LOGGING, + isDeleted + ? `Deleted ${appName} from runningApps map` + : `Unable to find or delete ${appName} from runningApps map` + ) // Load existing apps config const appConfig = await getAppByName(appName) if (!appConfig) { - console.log('App not found in config, adding it') - // App not found in config, add it - const newAppConfig = { name: appName, enabled: false, running: false, prefIndex: 5 } // 5 is the default index - await setAppData(newAppConfig) + console.log('App not found in config, nothing to set!') } else if (appConfig.enabled) { // App found but not enabled, enable it appConfig.enabled = false @@ -560,10 +563,6 @@ async function purgeApp(appName: string): Promise { console.log(`App ${appName} is already disabled`) } - // Remove the app from memory cache - const appDirectory = getAppFilePath(appName) - clearCache(appDirectory) - sendPrefData() } catch (error) { console.error('Error disabling app:', error) @@ -580,20 +579,24 @@ async function clearCache(dir: string): Promise { if (stats.isDirectory()) { // Recursively clear directories - //clearCache(itemPath) + clearCache(itemPath) } else if (stats.isFile()) { - // Resolve and clear file from cache - const resolvedPath = require.resolve(itemPath) - if (require.cache[resolvedPath]) { - delete require.cache[resolvedPath] - console.log(`Removed ${resolvedPath} from cache`) - dataListener.asyncEmit( - MESSAGE_TYPES.LOGGING, - `SERVER: Removed ${resolvedPath} from cache` - ) - } else { - console.log(`${resolvedPath} not in cache`) - dataListener.asyncEmit(MESSAGE_TYPES.LOGGING, `SERVER: ${resolvedPath} not in cache!`) + try { + // Resolve and clear file from cache + const resolvedPath = require.resolve(itemPath) + if (require.cache[resolvedPath]) { + delete require.cache[resolvedPath] + console.log(`Removed ${resolvedPath} from cache`) + dataListener.asyncEmit( + MESSAGE_TYPES.LOGGING, + `SERVER: Removed ${resolvedPath} from cache` + ) + } else { + console.log(`${resolvedPath} not in cache`) + dataListener.asyncEmit(MESSAGE_TYPES.LOGGING, `SERVER: ${resolvedPath} not in cache!`) + } + } catch (e) { + console.log(e) } } }) diff --git a/DeskThingServer/src/main/handlers/keyMapHandler.ts b/DeskThingServer/src/main/handlers/keyMapHandler.ts index e9a2949e..0bd6f0e2 100644 --- a/DeskThingServer/src/main/handlers/keyMapHandler.ts +++ b/DeskThingServer/src/main/handlers/keyMapHandler.ts @@ -612,6 +612,10 @@ const removeAction = (actionId: string): void => { saveMappings(mappings) } +/** + * Removes all keys and mappings relating to the App + * @param appId The ID of the app to remove + */ const removeAppData = (appId: string): void => { const mappings = loadMappings() diff --git a/DeskThingServer/src/main/index.ts b/DeskThingServer/src/main/index.ts index 633719a8..5478ee21 100644 --- a/DeskThingServer/src/main/index.ts +++ b/DeskThingServer/src/main/index.ts @@ -12,6 +12,7 @@ import { import { join } from 'path' import path from 'path' import icon from '../../resources/icon.ico?asset' +import linuxIcon from '../../resources/icon.png?asset' import { GithubRelease } from './types/types' import { ServerManifest } from './handlers/deviceHandler' import { Settings } from './stores/settingsStore' @@ -65,7 +66,7 @@ function createMainWindow(): BrowserWindow { icon: icon, show: false, autoHideMenuBar: true, - ...(process.platform === 'linux' ? { icon: icon } : {}), + ...(process.platform === 'linux' ? { icon: linuxIcon } : {}), webPreferences: { preload: join(__dirname, '../preload/index.js'), sandbox: false diff --git a/DeskThingServer/src/renderer/src/components/Sidebar.tsx b/DeskThingServer/src/renderer/src/components/Sidebar.tsx index 422d965d..f65622f2 100644 --- a/DeskThingServer/src/renderer/src/components/Sidebar.tsx +++ b/DeskThingServer/src/renderer/src/components/Sidebar.tsx @@ -119,7 +119,7 @@ const Sidebar: React.FC = ({ setCurrentView, currentView }) => { className="group sm:flex-col items-center flex-row-reverse flex sm:border p-2 rounded-xl border-zinc-500 hover:bg-zinc-900 hover:text-red-500" onClick={() => window.electron.ipcRenderer.send('shutdown')} > -

Close

+

Shutdown