diff --git a/src/Logic/Osm/OsmConnection.ts b/src/Logic/Osm/OsmConnection.ts index e59678b64e..24f8033674 100644 --- a/src/Logic/Osm/OsmConnection.ts +++ b/src/Logic/Osm/OsmConnection.ts @@ -20,7 +20,6 @@ interface OsmUserInfo { } export default class UserDetails { - public loggedIn = false public name = "Not logged in" public uid: number public csCount = 0 @@ -136,7 +135,6 @@ export class OsmConnection { const ud = this.userDetails.data ud.csCount = 5678 ud.uid = 42 - ud.loggedIn = true ud.unreadMessages = 0 ud.name = "Fake user" ud.totalMessages = 42 @@ -148,18 +146,9 @@ export class OsmConnection { this.UpdateCapabilities() this.isLoggedIn = this.userDetails.map( - (user) => - user.loggedIn && - (this.apiIsOnline.data === "unknown" || this.apiIsOnline.data === "online"), + (user) => user !== undefined && (this.apiIsOnline.data === "unknown" || this.apiIsOnline.data === "online"), [this.apiIsOnline] ) - this.isLoggedIn.addCallback((isLoggedIn) => { - if (this.userDetails.data.loggedIn == false && isLoggedIn == true) { - // We have an inconsistency: the userdetails say we _didn't_ log in, but this actor says we do - // This means someone attempted to toggle this; so we attempt to login! - this.AttemptLogin() - } - }) this._dryRun = options.dryRun ?? new UIEventSource(false) @@ -214,7 +203,6 @@ export class OsmConnection { public LogOut() { this.auth.logout() - this.userDetails.data.loggedIn = false this.userDetails.data.csCount = 0 this.userDetails.data.name = "" this.userDetails.ping() @@ -279,7 +267,6 @@ export class OsmConnection { const userInfo = details.getElementsByTagName("user")[0] const data = this.userDetails.data - data.loggedIn = true console.log("Login completed, userinfo is ", userInfo) data.name = userInfo.getAttribute("display_name") data.account_created = userInfo.getAttribute("account_created") diff --git a/src/Logic/Osm/OsmPreferences.ts b/src/Logic/Osm/OsmPreferences.ts index 165e688961..28cc4cccc6 100644 --- a/src/Logic/Osm/OsmPreferences.ts +++ b/src/Logic/Osm/OsmPreferences.ts @@ -1,8 +1,8 @@ import { Store, UIEventSource } from "../UIEventSource" import { OsmConnection } from "./OsmConnection" import { LocalStorageSource } from "../Web/LocalStorageSource" -import OSMAuthInstance = OSMAuth.osmAuth import { Utils } from "../../Utils" +import OSMAuthInstance = OSMAuth.osmAuth export class OsmPreferences { /** @@ -279,7 +279,7 @@ export class OsmPreferences { * @private */ private deleteKeyDirectly(k: string) { - if (!this.osmConnection.userDetails.data.loggedIn) { + if (!this.osmConnection.isLoggedIn.data) { console.debug(`Not saving preference ${k}: user not logged in`) return } @@ -312,7 +312,7 @@ export class OsmPreferences { * Deletes it if 'v' is undefined, null or empty */ private async uploadKeyDirectly(k: string, v: string) { - if (!this.osmConnection.userDetails.data.loggedIn) { + if (!this.osmConnection.isLoggedIn.data) { console.debug(`Not saving preference ${k}: user not logged in`) return } diff --git a/src/UI/Base/OpenJosm.svelte b/src/UI/Base/OpenJosm.svelte index e3bbb60886..ca43660c66 100644 --- a/src/UI/Base/OpenJosm.svelte +++ b/src/UI/Base/OpenJosm.svelte @@ -14,7 +14,7 @@ josmState.stabilized(15000).addCallbackD(() => josmState.setData(undefined)) const showButton = state.osmConnection.userDetails.map( - (ud) => ud.loggedIn && ud.csCount >= Constants.userJourney.historyLinkVisible + (ud) => ud?.csCount >= Constants.userJourney.historyLinkVisible ) function openJosm() { diff --git a/src/UI/Image/DeletableImage.svelte b/src/UI/Image/DeletableImage.svelte index 25db1d825b..a5e60e4a58 100644 --- a/src/UI/Image/DeletableImage.svelte +++ b/src/UI/Image/DeletableImage.svelte @@ -44,7 +44,7 @@ const imageInfo = await panoramax.imageInfo(image.id) let reporter_email: string = undefined const userdetails = state.userRelatedState.osmConnection.userDetails - if (userdetails.data.loggedIn) { + if (userdetails.data?.loggedIn) { reporter_email = userdetails.data.name + "@openstreetmap.org" } diff --git a/src/UI/Image/ImageCarousel.svelte b/src/UI/Image/ImageCarousel.svelte index b8fb8a14bc..c071c1d1a0 100644 --- a/src/UI/Image/ImageCarousel.svelte +++ b/src/UI/Image/ImageCarousel.svelte @@ -12,10 +12,6 @@ export let estimated: Store - images.addCallbackAndRun(imgs => { - console.log(">>><<< imgs are", imgs) - }) - {#if $estimated > 0 && $images.length < 1} diff --git a/src/UI/Popup/DeleteFlow/DeleteFlowState.ts b/src/UI/Popup/DeleteFlow/DeleteFlowState.ts index f9595b79aa..8d230413f7 100644 --- a/src/UI/Popup/DeleteFlow/DeleteFlowState.ts +++ b/src/UI/Popup/DeleteFlow/DeleteFlowState.ts @@ -54,7 +54,7 @@ export class DeleteFlowState { if (ud === undefined) { return undefined } - if (!ud.loggedIn) { + if (!ud) { return false } return ( diff --git a/src/UI/Popup/TagHint.svelte b/src/UI/Popup/TagHint.svelte index 099422e15e..e7eb543dc1 100644 --- a/src/UI/Popup/TagHint.svelte +++ b/src/UI/Popup/TagHint.svelte @@ -23,7 +23,7 @@ $: tagsExplanation = tags?.asHumanString(true, false, currentProperties) -{#if !userDetails || $userDetails.loggedIn} +{#if !userDetails}
{#if tags === undefined}