From 454ee6cf4cc023b7968dffaf15bda1a99225559b Mon Sep 17 00:00:00 2001 From: Anton Bracke Date: Tue, 22 Feb 2022 19:01:26 +0100 Subject: [PATCH] nits, fixes --- desktop/electron/src/auto-launch.ts | 6 ------ desktop/electron/src/ipc.ts | 2 +- desktop/electron/src/settings.ts | 18 ++++++++++++++++-- desktop/electron/src/tray.ts | 9 ++++++++- desktop/electron/src/window.ts | 6 ------ desktop/local-app/src/App.svelte | 9 --------- desktop/local-app/src/lib/Sidebar.svelte | 4 ---- desktop/local-app/src/views/Settings.svelte | 2 +- 8 files changed, 26 insertions(+), 30 deletions(-) diff --git a/desktop/electron/src/auto-launch.ts b/desktop/electron/src/auto-launch.ts index 3fac24bf..5ee4b948 100644 --- a/desktop/electron/src/auto-launch.ts +++ b/desktop/electron/src/auto-launch.ts @@ -7,12 +7,6 @@ import settings from "./settings"; export async function updateAutoLaunch() { let isAutoLaunchEnabled = settings.get("auto_launch_enabled"); - // set default to enabled - if (isAutoLaunchEnabled === undefined) { - settings.set("auto_launch_enabled", true); - isAutoLaunchEnabled = true; - } - // Don't run this in development if (electronIsDev) { return; diff --git a/desktop/electron/src/ipc.ts b/desktop/electron/src/ipc.ts index 563506aa..d7d3c733 100644 --- a/desktop/electron/src/ipc.ts +++ b/desktop/electron/src/ipc.ts @@ -44,7 +44,7 @@ export default () => { settings.get("servers") || [ // TODO: remove this default server { - _id: "1", + _id: `${Date.now()}-1`, name: "WA Demo", url: "https://play.staging.workadventu.re/@/tcm/workadventure/wa-village", }, diff --git a/desktop/electron/src/settings.ts b/desktop/electron/src/settings.ts index 935c4968..93862abc 100644 --- a/desktop/electron/src/settings.ts +++ b/desktop/electron/src/settings.ts @@ -6,13 +6,27 @@ export type SettingsData = { log_level: ElectronLog.LogLevel; auto_launch_enabled: boolean; servers: Server[]; - shortcuts: Record<"mute_toggle" | "camera_toggle", string | null>; + shortcuts: Record<"mute_toggle" | "camera_toggle", string>; }; let settings: SettingsData; +const defaultSettings: SettingsData = { + log_level: "info", + auto_launch_enabled: true, + servers: [], + shortcuts: { + mute_toggle: "", + camera_toggle: "", + }, +}; + async function init() { - settings = (await Settings.get()) as SettingsData; + let _settings = await Settings.get(); + if (_settings !== undefined) { + _settings = defaultSettings; + } + settings = _settings as SettingsData; } function get(): SettingsData; diff --git a/desktop/electron/src/tray.ts b/desktop/electron/src/tray.ts index 6cf45a2b..cc72b1aa 100644 --- a/desktop/electron/src/tray.ts +++ b/desktop/electron/src/tray.ts @@ -4,7 +4,7 @@ import { showAboutWindow } from "electron-util"; import * as autoUpdater from "./auto-updater"; import * as log from "./log"; -import { getWindow } from "./window"; +import { getAppView, getWindow } from "./window"; let tray: Tray | undefined; @@ -46,6 +46,13 @@ export function createTray() { log.openLog(); }, }, + { + label: "Open DevTools", + click() { + getWindow()?.webContents.openDevTools({ mode: "detach" }); + getAppView()?.webContents.openDevTools({ mode: "detach" }); + }, + }, { label: "About", click() { diff --git a/desktop/electron/src/window.ts b/desktop/electron/src/window.ts index 064d8141..86275f01 100644 --- a/desktop/electron/src/window.ts +++ b/desktop/electron/src/window.ts @@ -93,12 +93,6 @@ export async function createWindow() { mainWindow.once("ready-to-show", () => { mainWindow?.show(); - if (electronIsDev) { - // appView?.webContents.openDevTools({ - // mode: "detach", - // }); - // mainWindow?.webContents.openDevTools({ mode: "detach" }); - } }); mainWindow.webContents.on("did-finish-load", () => { diff --git a/desktop/local-app/src/App.svelte b/desktop/local-app/src/App.svelte index b0f9ca46..4ca46c9e 100644 --- a/desktop/local-app/src/App.svelte +++ b/desktop/local-app/src/App.svelte @@ -41,15 +41,6 @@ } main { - /* TODO */ background-color: #30343d; - - /* background-color: #2b2f37; */ - - /* color: #62727c; - border: 1px solid #62727c; */ - - /* border-color: #e1e4e8; - color: #e1e4e8; */ } diff --git a/desktop/local-app/src/lib/Sidebar.svelte b/desktop/local-app/src/lib/Sidebar.svelte index 9ffa2914..cbdbe746 100644 --- a/desktop/local-app/src/lib/Sidebar.svelte +++ b/desktop/local-app/src/lib/Sidebar.svelte @@ -21,10 +21,6 @@ return serverColors[i % serverColors.length]; } - selectedServer.subscribe((e) => { - console.log("selected server changed", e); - }); - $: serverWithSelection = $servers.map((s) => ({ ...s, isSelected: $selectedServer === s._id })) onMount(async () => { diff --git a/desktop/local-app/src/views/Settings.svelte b/desktop/local-app/src/views/Settings.svelte index 429945f5..3e9d978b 100644 --- a/desktop/local-app/src/views/Settings.svelte +++ b/desktop/local-app/src/views/Settings.svelte @@ -19,7 +19,7 @@ }); async function saveShortcut(key: keyof SettingsData["shortcuts"], value: string) { - const shortcuts = get(settings)['shortcuts'] || { "camera_toggle": "", "mute_toggle": "" }; + const shortcuts = get(settings)['shortcuts']; shortcuts[key] = value; settings.update((s) => ({ ...s, shortcuts })); await api.saveSetting("shortcuts", shortcuts);