forked from MapComplete/MapComplete
		
	Refactoring: remove obsolete 'loggedIn' on userdetails-object
This commit is contained in:
		
							parent
							
								
									1b3066cc28
								
							
						
					
					
						commit
						3bf099c14a
					
				
					 7 changed files with 8 additions and 25 deletions
				
			
		|  | @ -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<boolean>(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") | ||||
|  |  | |||
|  | @ -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 | ||||
|         } | ||||
|  |  | |||
|  | @ -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() { | ||||
|  |  | |||
|  | @ -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" | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -12,10 +12,6 @@ | |||
| 
 | ||||
|   export let estimated: Store<number> | ||||
| 
 | ||||
|   images.addCallbackAndRun(imgs => { | ||||
|     console.log(">>><<< imgs are", imgs) | ||||
|   }) | ||||
| 
 | ||||
| </script> | ||||
| {#if $estimated > 0 && $images.length < 1} | ||||
|   <LoadingPlaceholder /> | ||||
|  |  | |||
|  | @ -54,7 +54,7 @@ export class DeleteFlowState { | |||
|             if (ud === undefined) { | ||||
|                 return undefined | ||||
|             } | ||||
|             if (!ud.loggedIn) { | ||||
|             if (!ud) { | ||||
|                 return false | ||||
|             } | ||||
|             return ( | ||||
|  |  | |||
|  | @ -23,7 +23,7 @@ | |||
|   $: tagsExplanation = tags?.asHumanString(true, false, currentProperties) | ||||
| </script> | ||||
| 
 | ||||
| {#if !userDetails || $userDetails.loggedIn} | ||||
| {#if !userDetails} | ||||
|   <div class="break-words" style="word-break: break-word"> | ||||
|     {#if tags === undefined} | ||||
|       <slot name="no-tags"><Tr cls="subtle" t={Translations.t.general.noTagsSelected} /></slot> | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue