forked from MapComplete/MapComplete
		
	Fix: fix broken index page for anonymous users
This commit is contained in:
		
							parent
							
								
									d9c8785d9b
								
							
						
					
					
						commit
						6260bc2897
					
				
					 2 changed files with 9 additions and 6 deletions
				
			
		|  | @ -350,10 +350,10 @@ export default class UserRelatedState { | |||
|      * List of all hidden themes that have been seen before | ||||
|      * @param osmConnection | ||||
|      */ | ||||
|     public static initDiscoveredHiddenThemes(osmConnection: OsmConnection): Store<string[]> { | ||||
|     public static initDiscoveredHiddenThemes(osmConnection: OsmConnection): Store<undefined | string[]> { | ||||
|         const prefix = "mapcomplete-hidden-theme-" | ||||
|         const userPreferences = osmConnection.preferencesHandler.allPreferences | ||||
|         return userPreferences.map((preferences) => | ||||
|         return userPreferences.mapD((preferences) => | ||||
|             Object.keys(preferences) | ||||
|                 .filter((key) => key.startsWith(prefix)) | ||||
|                 .map((key) => key.substring(prefix.length, key.length - "-enabled".length)) | ||||
|  |  | |||
|  | @ -40,7 +40,7 @@ | |||
|   const tu = Translations.t.general | ||||
|   const tr = Translations.t.general.morescreen | ||||
| 
 | ||||
|   let userLanguages = osmConnection.userDetails.map((ud) => ud.languages) | ||||
|   let userLanguages = osmConnection.userDetails.map((ud) => ud?.languages ?? []) | ||||
|   let search: UIEventSource<string | undefined> = new UIEventSource<string>("") | ||||
|   let searchStable = search.stabilized(100) | ||||
| 
 | ||||
|  | @ -52,12 +52,12 @@ | |||
|   const hiddenThemes: MinimalThemeInformation[] = ThemeSearch.officialThemes.themes.filter( | ||||
|     (th) => th.hideFromOverview === true | ||||
|   ) | ||||
|   let visitedHiddenThemes: Store<MinimalThemeInformation[]> = | ||||
|     UserRelatedState.initDiscoveredHiddenThemes(state.osmConnection).map((knownIds) => | ||||
|   let visitedHiddenThemes: Store<undefined | MinimalThemeInformation[]> = | ||||
|     UserRelatedState.initDiscoveredHiddenThemes(state.osmConnection).mapD((knownIds) => | ||||
|       hiddenThemes.filter( | ||||
|         (theme) => | ||||
|           knownIds.indexOf(theme.id) >= 0 || | ||||
|           state.osmConnection.userDetails.data.name === "Pieter Vander Vennet" | ||||
|           state.osmConnection.userDetails?.data?.name === "Pieter Vander Vennet" | ||||
|       ) | ||||
|     ) | ||||
| 
 | ||||
|  | @ -67,6 +67,9 @@ | |||
|   function filtered(themes: Store<MinimalThemeInformation[]>): Store<MinimalThemeInformation[]> { | ||||
|     return searchStable.map( | ||||
|       (search) => { | ||||
|         if (!themes.data) { | ||||
|           return [] | ||||
|         } | ||||
|         if (!search) { | ||||
|           return themes.data | ||||
|         } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue