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 { | export default class UserDetails { | ||||||
|     public loggedIn = false |  | ||||||
|     public name = "Not logged in" |     public name = "Not logged in" | ||||||
|     public uid: number |     public uid: number | ||||||
|     public csCount = 0 |     public csCount = 0 | ||||||
|  | @ -136,7 +135,6 @@ export class OsmConnection { | ||||||
|             const ud = this.userDetails.data |             const ud = this.userDetails.data | ||||||
|             ud.csCount = 5678 |             ud.csCount = 5678 | ||||||
|             ud.uid = 42 |             ud.uid = 42 | ||||||
|             ud.loggedIn = true |  | ||||||
|             ud.unreadMessages = 0 |             ud.unreadMessages = 0 | ||||||
|             ud.name = "Fake user" |             ud.name = "Fake user" | ||||||
|             ud.totalMessages = 42 |             ud.totalMessages = 42 | ||||||
|  | @ -148,18 +146,9 @@ export class OsmConnection { | ||||||
|         this.UpdateCapabilities() |         this.UpdateCapabilities() | ||||||
| 
 | 
 | ||||||
|         this.isLoggedIn = this.userDetails.map( |         this.isLoggedIn = this.userDetails.map( | ||||||
|             (user) => |             (user) => user !== undefined && (this.apiIsOnline.data === "unknown" || this.apiIsOnline.data === "online"), | ||||||
|                 user.loggedIn && |  | ||||||
|                 (this.apiIsOnline.data === "unknown" || this.apiIsOnline.data === "online"), |  | ||||||
|             [this.apiIsOnline] |             [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) |         this._dryRun = options.dryRun ?? new UIEventSource<boolean>(false) | ||||||
| 
 | 
 | ||||||
|  | @ -214,7 +203,6 @@ export class OsmConnection { | ||||||
| 
 | 
 | ||||||
|     public LogOut() { |     public LogOut() { | ||||||
|         this.auth.logout() |         this.auth.logout() | ||||||
|         this.userDetails.data.loggedIn = false |  | ||||||
|         this.userDetails.data.csCount = 0 |         this.userDetails.data.csCount = 0 | ||||||
|         this.userDetails.data.name = "" |         this.userDetails.data.name = "" | ||||||
|         this.userDetails.ping() |         this.userDetails.ping() | ||||||
|  | @ -279,7 +267,6 @@ export class OsmConnection { | ||||||
|                 const userInfo = details.getElementsByTagName("user")[0] |                 const userInfo = details.getElementsByTagName("user")[0] | ||||||
| 
 | 
 | ||||||
|                 const data = this.userDetails.data |                 const data = this.userDetails.data | ||||||
|                 data.loggedIn = true |  | ||||||
|                 console.log("Login completed, userinfo is ", userInfo) |                 console.log("Login completed, userinfo is ", userInfo) | ||||||
|                 data.name = userInfo.getAttribute("display_name") |                 data.name = userInfo.getAttribute("display_name") | ||||||
|                 data.account_created = userInfo.getAttribute("account_created") |                 data.account_created = userInfo.getAttribute("account_created") | ||||||
|  |  | ||||||
|  | @ -1,8 +1,8 @@ | ||||||
| import { Store, UIEventSource } from "../UIEventSource" | import { Store, UIEventSource } from "../UIEventSource" | ||||||
| import { OsmConnection } from "./OsmConnection" | import { OsmConnection } from "./OsmConnection" | ||||||
| import { LocalStorageSource } from "../Web/LocalStorageSource" | import { LocalStorageSource } from "../Web/LocalStorageSource" | ||||||
| import OSMAuthInstance = OSMAuth.osmAuth |  | ||||||
| import { Utils } from "../../Utils" | import { Utils } from "../../Utils" | ||||||
|  | import OSMAuthInstance = OSMAuth.osmAuth | ||||||
| 
 | 
 | ||||||
| export class OsmPreferences { | export class OsmPreferences { | ||||||
|     /** |     /** | ||||||
|  | @ -279,7 +279,7 @@ export class OsmPreferences { | ||||||
|      * @private |      * @private | ||||||
|      */ |      */ | ||||||
|     private deleteKeyDirectly(k: string) { |     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`) |             console.debug(`Not saving preference ${k}: user not logged in`) | ||||||
|             return |             return | ||||||
|         } |         } | ||||||
|  | @ -312,7 +312,7 @@ export class OsmPreferences { | ||||||
|      * Deletes it if 'v' is undefined, null or empty |      * Deletes it if 'v' is undefined, null or empty | ||||||
|      */ |      */ | ||||||
|     private async uploadKeyDirectly(k: string, v: string) { |     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`) |             console.debug(`Not saving preference ${k}: user not logged in`) | ||||||
|             return |             return | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  | @ -14,7 +14,7 @@ | ||||||
|   josmState.stabilized(15000).addCallbackD(() => josmState.setData(undefined)) |   josmState.stabilized(15000).addCallbackD(() => josmState.setData(undefined)) | ||||||
| 
 | 
 | ||||||
|   const showButton = state.osmConnection.userDetails.map( |   const showButton = state.osmConnection.userDetails.map( | ||||||
|     (ud) => ud.loggedIn && ud.csCount >= Constants.userJourney.historyLinkVisible |     (ud) => ud?.csCount >= Constants.userJourney.historyLinkVisible | ||||||
|   ) |   ) | ||||||
| 
 | 
 | ||||||
|   function openJosm() { |   function openJosm() { | ||||||
|  |  | ||||||
|  | @ -44,7 +44,7 @@ | ||||||
|     const imageInfo = await panoramax.imageInfo(image.id) |     const imageInfo = await panoramax.imageInfo(image.id) | ||||||
|     let reporter_email: string = undefined |     let reporter_email: string = undefined | ||||||
|     const userdetails = state.userRelatedState.osmConnection.userDetails |     const userdetails = state.userRelatedState.osmConnection.userDetails | ||||||
|     if (userdetails.data.loggedIn) { |     if (userdetails.data?.loggedIn) { | ||||||
|       reporter_email = userdetails.data.name + "@openstreetmap.org" |       reporter_email = userdetails.data.name + "@openstreetmap.org" | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -12,10 +12,6 @@ | ||||||
| 
 | 
 | ||||||
|   export let estimated: Store<number> |   export let estimated: Store<number> | ||||||
| 
 | 
 | ||||||
|   images.addCallbackAndRun(imgs => { |  | ||||||
|     console.log(">>><<< imgs are", imgs) |  | ||||||
|   }) |  | ||||||
| 
 |  | ||||||
| </script> | </script> | ||||||
| {#if $estimated > 0 && $images.length < 1} | {#if $estimated > 0 && $images.length < 1} | ||||||
|   <LoadingPlaceholder /> |   <LoadingPlaceholder /> | ||||||
|  |  | ||||||
|  | @ -54,7 +54,7 @@ export class DeleteFlowState { | ||||||
|             if (ud === undefined) { |             if (ud === undefined) { | ||||||
|                 return undefined |                 return undefined | ||||||
|             } |             } | ||||||
|             if (!ud.loggedIn) { |             if (!ud) { | ||||||
|                 return false |                 return false | ||||||
|             } |             } | ||||||
|             return ( |             return ( | ||||||
|  |  | ||||||
|  | @ -23,7 +23,7 @@ | ||||||
|   $: tagsExplanation = tags?.asHumanString(true, false, currentProperties) |   $: tagsExplanation = tags?.asHumanString(true, false, currentProperties) | ||||||
| </script> | </script> | ||||||
| 
 | 
 | ||||||
| {#if !userDetails || $userDetails.loggedIn} | {#if !userDetails} | ||||||
|   <div class="break-words" style="word-break: break-word"> |   <div class="break-words" style="word-break: break-word"> | ||||||
|     {#if tags === undefined} |     {#if tags === undefined} | ||||||
|       <slot name="no-tags"><Tr cls="subtle" t={Translations.t.general.noTagsSelected} /></slot> |       <slot name="no-tags"><Tr cls="subtle" t={Translations.t.general.noTagsSelected} /></slot> | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue