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
 | 
					     * List of all hidden themes that have been seen before
 | 
				
			||||||
     * @param osmConnection
 | 
					     * @param osmConnection
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public static initDiscoveredHiddenThemes(osmConnection: OsmConnection): Store<string[]> {
 | 
					    public static initDiscoveredHiddenThemes(osmConnection: OsmConnection): Store<undefined | string[]> {
 | 
				
			||||||
        const prefix = "mapcomplete-hidden-theme-"
 | 
					        const prefix = "mapcomplete-hidden-theme-"
 | 
				
			||||||
        const userPreferences = osmConnection.preferencesHandler.allPreferences
 | 
					        const userPreferences = osmConnection.preferencesHandler.allPreferences
 | 
				
			||||||
        return userPreferences.map((preferences) =>
 | 
					        return userPreferences.mapD((preferences) =>
 | 
				
			||||||
            Object.keys(preferences)
 | 
					            Object.keys(preferences)
 | 
				
			||||||
                .filter((key) => key.startsWith(prefix))
 | 
					                .filter((key) => key.startsWith(prefix))
 | 
				
			||||||
                .map((key) => key.substring(prefix.length, key.length - "-enabled".length))
 | 
					                .map((key) => key.substring(prefix.length, key.length - "-enabled".length))
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -40,7 +40,7 @@
 | 
				
			||||||
  const tu = Translations.t.general
 | 
					  const tu = Translations.t.general
 | 
				
			||||||
  const tr = Translations.t.general.morescreen
 | 
					  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 search: UIEventSource<string | undefined> = new UIEventSource<string>("")
 | 
				
			||||||
  let searchStable = search.stabilized(100)
 | 
					  let searchStable = search.stabilized(100)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -52,12 +52,12 @@
 | 
				
			||||||
  const hiddenThemes: MinimalThemeInformation[] = ThemeSearch.officialThemes.themes.filter(
 | 
					  const hiddenThemes: MinimalThemeInformation[] = ThemeSearch.officialThemes.themes.filter(
 | 
				
			||||||
    (th) => th.hideFromOverview === true
 | 
					    (th) => th.hideFromOverview === true
 | 
				
			||||||
  )
 | 
					  )
 | 
				
			||||||
  let visitedHiddenThemes: Store<MinimalThemeInformation[]> =
 | 
					  let visitedHiddenThemes: Store<undefined | MinimalThemeInformation[]> =
 | 
				
			||||||
    UserRelatedState.initDiscoveredHiddenThemes(state.osmConnection).map((knownIds) =>
 | 
					    UserRelatedState.initDiscoveredHiddenThemes(state.osmConnection).mapD((knownIds) =>
 | 
				
			||||||
      hiddenThemes.filter(
 | 
					      hiddenThemes.filter(
 | 
				
			||||||
        (theme) =>
 | 
					        (theme) =>
 | 
				
			||||||
          knownIds.indexOf(theme.id) >= 0 ||
 | 
					          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[]> {
 | 
					  function filtered(themes: Store<MinimalThemeInformation[]>): Store<MinimalThemeInformation[]> {
 | 
				
			||||||
    return searchStable.map(
 | 
					    return searchStable.map(
 | 
				
			||||||
      (search) => {
 | 
					      (search) => {
 | 
				
			||||||
 | 
					        if (!themes.data) {
 | 
				
			||||||
 | 
					          return []
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        if (!search) {
 | 
					        if (!search) {
 | 
				
			||||||
          return themes.data
 | 
					          return themes.data
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue