UX: don't check for messages and being online every 5m in studio, fix #1830

This commit is contained in:
Pieter Vander Vennet 2024-04-01 02:40:21 +02:00
parent 040e0fd8bf
commit 45f7043131
2 changed files with 11 additions and 1 deletions

View file

@ -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<boolean>
@ -59,12 +60,17 @@ export class OsmConnection {
oauth_token?: UIEventSource<string>
// 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) {

View file

@ -42,6 +42,7 @@
)
let osmConnection = new OsmConnection({
oauth_token,
checkOnlineRegularly: false
})
const expertMode = UIEventSource.asBoolean(
osmConnection.GetPreference("studio-expert-mode", "false", {