From da6b5b9f606aecfc024a0a146c5775cda95886f2 Mon Sep 17 00:00:00 2001 From: Anton Bracke Date: Wed, 23 Feb 2022 11:49:42 +0100 Subject: [PATCH] fix leave server selected after opening once --- desktop/electron/src/ipc.ts | 2 +- desktop/electron/src/window.ts | 6 ++++-- desktop/local-app/src/views/Server.svelte | 7 +------ 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/desktop/electron/src/ipc.ts b/desktop/electron/src/ipc.ts index 462c4e8d..f8083c3f 100644 --- a/desktop/electron/src/ipc.ts +++ b/desktop/electron/src/ipc.ts @@ -4,7 +4,7 @@ import { createAndShowNotification } from "./notification"; import { Server } from "./preload-local-app/types"; import settings, { SettingsData } from "./settings"; import { loadShortcuts, setShortcutsEnabled } from "./shortcuts"; -import { getAppView, getWindow, hideAppView, showAppView } from "./window"; +import { getAppView, hideAppView, showAppView } from "./window"; // import fetch from "node-fetch"; export function emitMuteToggle() { diff --git a/desktop/electron/src/window.ts b/desktop/electron/src/window.ts index 68fa9a9c..dd2203be 100644 --- a/desktop/electron/src/window.ts +++ b/desktop/electron/src/window.ts @@ -6,8 +6,9 @@ import { loadCustomScheme } from "./serve"; let mainWindow: BrowserWindow | undefined; let appView: BrowserView | undefined; +let appViewUrl = ""; -const sidebarWidth = 75; +const sidebarWidth = 80; export function getWindow() { return mainWindow; @@ -128,8 +129,9 @@ export function showAppView(url?: string) { } mainWindow.addBrowserView(appView); - if (url) { + if (url && url !== appViewUrl) { appView.webContents.loadURL(url); + appViewUrl = url; } } diff --git a/desktop/local-app/src/views/Server.svelte b/desktop/local-app/src/views/Server.svelte index 7b086101..892d29eb 100644 --- a/desktop/local-app/src/views/Server.svelte +++ b/desktop/local-app/src/views/Server.svelte @@ -2,7 +2,7 @@ import { onDestroy, onMount } from "svelte"; import { useParams } from "svelte-navigator"; - import { selectServer, servers, selectedServer } from "~/store"; + import { selectServer, servers } from "~/store"; import { api } from "~/lib/ipc"; const params = useParams(); @@ -11,13 +11,8 @@ selectServer(_params.id); }); - onMount(async () => { - await selectServer($params.id); - }); - onDestroy(async () => { await api.showLocalApp(); - $selectedServer = ""; }); $: server = $servers.find(({ _id }) => _id === $params.id);