forked from MapComplete/MapComplete
		
	Fix: URL-parameter language disables the language picker, fix #1506
This commit is contained in:
		
							parent
							
								
									58f526734d
								
							
						
					
					
						commit
						2f5c89f8c5
					
				
					 5 changed files with 36 additions and 6 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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -57,6 +57,9 @@ export class QueryParameters {
 | 
			
		|||
        this.init()
 | 
			
		||||
        return QueryParameters._wasInitialized.has(key)
 | 
			
		||||
    }
 | 
			
		||||
    public static initializedParameters(): ReadonlyArray<string> {
 | 
			
		||||
        return Array.from(QueryParameters._wasInitialized.keys())
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static addOrder(key) {
 | 
			
		||||
        if (this.order.indexOf(key) < 0) {
 | 
			
		||||
| 
						 | 
				
			
			@ -131,5 +134,4 @@ export class QueryParameters {
 | 
			
		|||
        QueryParameters._wasInitialized.clear()
 | 
			
		||||
        QueryParameters.order = []
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue