forked from MapComplete/MapComplete
		
	Fix: URL-parameter language disables the language picker, fix #1506
This commit is contained in:
		
							parent
							
								
									aaaf7f4cab
								
							
						
					
					
						commit
						3ca8ba18fd
					
				
					 5 changed files with 36 additions and 5 deletions
				
			
		|  | @ -15,6 +15,7 @@ import Locale from "../../UI/i18n/Locale" | |||
| import LinkToWeblate from "../../UI/Base/LinkToWeblate" | ||||
| import FeatureSwitchState from "./FeatureSwitchState" | ||||
| import Constants from "../../Models/Constants" | ||||
| import { QueryParameters } from "../Web/QueryParameters" | ||||
| 
 | ||||
| /** | ||||
|  * The part of the state which keeps track of user-related stuff, e.g. the OSM-connection, | ||||
|  | @ -93,13 +94,21 @@ export default class UserRelatedState { | |||
|             this.osmConnection.GetLongPreference("identity", "mangrove") | ||||
|         ) | ||||
| 
 | ||||
|         this.language.addCallbackAndRunD((language) => Locale.language.setData(language)) | ||||
| 
 | ||||
|         this.installedUserThemes = this.InitInstalledUserThemes() | ||||
| 
 | ||||
|         this.homeLocation = this.initHomeLocation() | ||||
| 
 | ||||
|         this.preferencesAsTags = this.initAmendedPrefs(layout, featureSwitches) | ||||
| 
 | ||||
|         this.syncLanguage() | ||||
|     } | ||||
| 
 | ||||
|     private syncLanguage() { | ||||
|         if (QueryParameters.wasInitialized("language")) { | ||||
|             return | ||||
|         } | ||||
| 
 | ||||
|         this.language.addCallbackAndRunD((language) => Locale.language.setData(language)) | ||||
|     } | ||||
| 
 | ||||
|     private static initUserRelatedState(): LayerConfig { | ||||
|  | @ -246,6 +255,10 @@ export default class UserRelatedState { | |||
|             amendedPrefs.data["__userjourney_" + key] = Constants.userJourney[key] | ||||
|         } | ||||
| 
 | ||||
|         for (const key of QueryParameters.initializedParameters()) { | ||||
|             amendedPrefs.data["__url_parameter_initialized:" + key] = "yes" | ||||
|         } | ||||
| 
 | ||||
|         const osmConnection = this.osmConnection | ||||
|         osmConnection.preferencesHandler.preferences.addCallback((newPrefs) => { | ||||
|             for (const k in newPrefs) { | ||||
|  | @ -268,6 +281,7 @@ export default class UserRelatedState { | |||
|         }) | ||||
|         const usersettingsConfig = UserRelatedState.usersettingsConfig | ||||
|         const translationMode = osmConnection.GetPreference("translation-mode") | ||||
| 
 | ||||
|         Locale.language.mapD( | ||||
|             (language) => { | ||||
|                 amendedPrefs.data["_language"] = language | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue