From 45f7043131630dbecf3040a7850f864847c3a65c Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Mon, 1 Apr 2024 02:40:21 +0200 Subject: [PATCH] UX: don't check for messages and being online every 5m in studio, fix #1830 --- src/Logic/Osm/OsmConnection.ts | 11 ++++++++++- src/UI/StudioGUI.svelte | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Logic/Osm/OsmConnection.ts b/src/Logic/Osm/OsmConnection.ts index b97bc4473..048417c2a 100644 --- a/src/Logic/Osm/OsmConnection.ts +++ b/src/Logic/Osm/OsmConnection.ts @@ -52,6 +52,7 @@ export class OsmConnection { private readonly _iframeMode: Boolean | boolean private readonly _singlePage: boolean private isChecking = false + private readonly _doCheckRegularly constructor(options?: { dryRun?: Store @@ -59,12 +60,17 @@ export class OsmConnection { oauth_token?: UIEventSource // Used to keep multiple changesets open and to write to the correct changeset singlePage?: boolean - attemptLogin?: true | boolean + attemptLogin?: true | boolean, + /** + * If true: automatically check if we're still online every 5 minutes + fetch messages + */ + checkOnlineRegularly?: true | boolean }) { options ??= {} this.fakeUser = options?.fakeUser ?? false this._singlePage = options?.singlePage ?? true this._oauth_config = Constants.osmAuthConfig + this._doCheckRegularly = options?.checkOnlineRegularly ?? true console.debug("Using backend", this._oauth_config.url) this._iframeMode = Utils.runningFromConsole ? false : window !== window.top @@ -544,6 +550,9 @@ export class OsmConnection { if (this.isChecking) { return } + if(!this._doCheckRegularly){ + return + } this.isChecking = true Stores.Chronic(5 * 60 * 1000).addCallback((_) => { if (self.isLoggedIn.data) { diff --git a/src/UI/StudioGUI.svelte b/src/UI/StudioGUI.svelte index 7ce1f02b6..d70172907 100644 --- a/src/UI/StudioGUI.svelte +++ b/src/UI/StudioGUI.svelte @@ -42,6 +42,7 @@ ) let osmConnection = new OsmConnection({ oauth_token, + checkOnlineRegularly: false }) const expertMode = UIEventSource.asBoolean( osmConnection.GetPreference("studio-expert-mode", "false", {