forked from MapComplete/MapComplete
		
	Fix: build
This commit is contained in:
		
							parent
							
								
									5644c7a8b8
								
							
						
					
					
						commit
						29ee113e30
					
				
					 1 changed files with 43 additions and 40 deletions
				
			
		| 
						 | 
					@ -1,16 +1,16 @@
 | 
				
			||||||
import LayoutConfig from "../../Models/ThemeConfig/LayoutConfig"
 | 
					import LayoutConfig from "../../Models/ThemeConfig/LayoutConfig"
 | 
				
			||||||
import { OsmConnection } from "../Osm/OsmConnection"
 | 
					import {OsmConnection} from "../Osm/OsmConnection"
 | 
				
			||||||
import { MangroveIdentity } from "../Web/MangroveReviews"
 | 
					import {MangroveIdentity} from "../Web/MangroveReviews"
 | 
				
			||||||
import { Store, Stores, UIEventSource } from "../UIEventSource"
 | 
					import {Store, Stores, UIEventSource} from "../UIEventSource"
 | 
				
			||||||
import StaticFeatureSource from "../FeatureSource/Sources/StaticFeatureSource"
 | 
					import StaticFeatureSource from "../FeatureSource/Sources/StaticFeatureSource"
 | 
				
			||||||
import { FeatureSource } from "../FeatureSource/FeatureSource"
 | 
					import {FeatureSource} from "../FeatureSource/FeatureSource"
 | 
				
			||||||
import { Feature } from "geojson"
 | 
					import {Feature} from "geojson"
 | 
				
			||||||
import { Utils } from "../../Utils"
 | 
					import {Utils} from "../../Utils"
 | 
				
			||||||
import translators from "../../assets/translators.json"
 | 
					import translators from "../../assets/translators.json"
 | 
				
			||||||
import codeContributors from "../../assets/contributors.json"
 | 
					import codeContributors from "../../assets/contributors.json"
 | 
				
			||||||
import LayerConfig from "../../Models/ThemeConfig/LayerConfig"
 | 
					import LayerConfig from "../../Models/ThemeConfig/LayerConfig"
 | 
				
			||||||
import { LayerConfigJson } from "../../Models/ThemeConfig/Json/LayerConfigJson"
 | 
					import {LayerConfigJson} from "../../Models/ThemeConfig/Json/LayerConfigJson"
 | 
				
			||||||
import usersettings from "../../assets/generated/layers/usersettings.json"
 | 
					import usersettings from "../../assets/generated/usersettings.json"
 | 
				
			||||||
import Locale from "../../UI/i18n/Locale"
 | 
					import Locale from "../../UI/i18n/Locale"
 | 
				
			||||||
import LinkToWeblate from "../../UI/Base/LinkToWeblate"
 | 
					import LinkToWeblate from "../../UI/Base/LinkToWeblate"
 | 
				
			||||||
import FeatureSwitchState from "./FeatureSwitchState"
 | 
					import FeatureSwitchState from "./FeatureSwitchState"
 | 
				
			||||||
| 
						 | 
					@ -21,6 +21,9 @@ import Constants from "../../Models/Constants";
 | 
				
			||||||
 * which layers they enabled, ...
 | 
					 * which layers they enabled, ...
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
export default class UserRelatedState {
 | 
					export default class UserRelatedState {
 | 
				
			||||||
 | 
					    public static readonly usersettingsConfig = UserRelatedState.initUserRelatedState()
 | 
				
			||||||
 | 
					    public static readonly availableUserSettingsIds: string[] =
 | 
				
			||||||
 | 
					        UserRelatedState.usersettingsConfig?.tagRenderings?.map((tr) => tr.id) ?? []
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     The user credentials
 | 
					     The user credentials
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
| 
						 | 
					@ -29,15 +32,10 @@ export default class UserRelatedState {
 | 
				
			||||||
     * The key for mangrove
 | 
					     * The key for mangrove
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public readonly mangroveIdentity: MangroveIdentity
 | 
					    public readonly mangroveIdentity: MangroveIdentity
 | 
				
			||||||
 | 
					 | 
				
			||||||
    public readonly installedUserThemes: Store<string[]>
 | 
					    public readonly installedUserThemes: Store<string[]>
 | 
				
			||||||
 | 
					 | 
				
			||||||
    public readonly showAllQuestionsAtOnce: UIEventSource<boolean>
 | 
					    public readonly showAllQuestionsAtOnce: UIEventSource<boolean>
 | 
				
			||||||
    public readonly showTags:  UIEventSource<"no" | undefined | "always" | "yes">;
 | 
					    public readonly showTags: UIEventSource<"no" | undefined | "always" | "yes">;
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public readonly homeLocation: FeatureSource
 | 
					    public readonly homeLocation: FeatureSource
 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * The number of seconds that the GPS-locations are stored in memory.
 | 
					     * The number of seconds that the GPS-locations are stored in memory.
 | 
				
			||||||
     * Time in seconds
 | 
					     * Time in seconds
 | 
				
			||||||
| 
						 | 
					@ -46,18 +44,11 @@ export default class UserRelatedState {
 | 
				
			||||||
        7 * 24 * 60 * 60,
 | 
					        7 * 24 * 60 * 60,
 | 
				
			||||||
        "gps_location_retention"
 | 
					        "gps_location_retention"
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Preferences as tags exposes many preferences and state properties as record.
 | 
					     * Preferences as tags exposes many preferences and state properties as record.
 | 
				
			||||||
     * This is used to bridge the internal state with the usersettings.json layerconfig file
 | 
					     * This is used to bridge the internal state with the usersettings.json layerconfig file
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public readonly preferencesAsTags: UIEventSource<Record<string, string>>
 | 
					    public readonly preferencesAsTags: UIEventSource<Record<string, string>>
 | 
				
			||||||
    public static readonly usersettingsConfig = new LayerConfig(
 | 
					 | 
				
			||||||
        <LayerConfigJson>usersettings,
 | 
					 | 
				
			||||||
        "userinformationpanel"
 | 
					 | 
				
			||||||
    )
 | 
					 | 
				
			||||||
    public static readonly availableUserSettingsIds: string[] =
 | 
					 | 
				
			||||||
        UserRelatedState.usersettingsConfig.tagRenderings.map((tr) => tr.id)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    constructor(
 | 
					    constructor(
 | 
				
			||||||
        osmConnection: OsmConnection,
 | 
					        osmConnection: OsmConnection,
 | 
				
			||||||
| 
						 | 
					@ -92,7 +83,7 @@ export default class UserRelatedState {
 | 
				
			||||||
                    "Either 'true' or 'false'. If set, all questions will be shown all at once",
 | 
					                    "Either 'true' or 'false'. If set, all questions will be shown all at once",
 | 
				
			||||||
            })
 | 
					            })
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        this.showTags = <UIEventSource<any>> this.osmConnection.GetPreference("show_tags")
 | 
					        this.showTags = <UIEventSource<any>>this.osmConnection.GetPreference("show_tags")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.mangroveIdentity = new MangroveIdentity(
 | 
					        this.mangroveIdentity = new MangroveIdentity(
 | 
				
			||||||
            this.osmConnection.GetLongPreference("identity", "mangrove")
 | 
					            this.osmConnection.GetLongPreference("identity", "mangrove")
 | 
				
			||||||
| 
						 | 
					@ -107,15 +98,27 @@ export default class UserRelatedState {
 | 
				
			||||||
        this.preferencesAsTags = this.initAmendedPrefs(layout, featureSwitches)
 | 
					        this.preferencesAsTags = this.initAmendedPrefs(layout, featureSwitches)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private static initUserRelatedState(): LayerConfig {
 | 
				
			||||||
 | 
					        try{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return new LayerConfig(
 | 
				
			||||||
 | 
					            <LayerConfigJson>usersettings,
 | 
				
			||||||
 | 
					            "userinformationpanel"
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
 | 
					        }catch(e){
 | 
				
			||||||
 | 
					            return undefined
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public GetUnofficialTheme(id: string):
 | 
					    public GetUnofficialTheme(id: string):
 | 
				
			||||||
        | {
 | 
					        | {
 | 
				
			||||||
              id: string
 | 
					        id: string
 | 
				
			||||||
              icon: string
 | 
					        icon: string
 | 
				
			||||||
              title: any
 | 
					        title: any
 | 
				
			||||||
              shortDescription: any
 | 
					        shortDescription: any
 | 
				
			||||||
              definition?: any
 | 
					        definition?: any
 | 
				
			||||||
              isOfficial: boolean
 | 
					        isOfficial: boolean
 | 
				
			||||||
          }
 | 
					    }
 | 
				
			||||||
        | undefined {
 | 
					        | undefined {
 | 
				
			||||||
        console.log("GETTING UNOFFICIAL THEME")
 | 
					        console.log("GETTING UNOFFICIAL THEME")
 | 
				
			||||||
        const pref = this.osmConnection.GetLongPreference("unofficial-theme-" + id)
 | 
					        const pref = this.osmConnection.GetLongPreference("unofficial-theme-" + id)
 | 
				
			||||||
| 
						 | 
					@ -140,8 +143,8 @@ export default class UserRelatedState {
 | 
				
			||||||
        } catch (e) {
 | 
					        } catch (e) {
 | 
				
			||||||
            console.warn(
 | 
					            console.warn(
 | 
				
			||||||
                "Removing theme " +
 | 
					                "Removing theme " +
 | 
				
			||||||
                    id +
 | 
					                id +
 | 
				
			||||||
                    " as it could not be parsed from the preferences; the content is:",
 | 
					                " as it could not be parsed from the preferences; the content is:",
 | 
				
			||||||
                str
 | 
					                str
 | 
				
			||||||
            )
 | 
					            )
 | 
				
			||||||
            pref.setData(null)
 | 
					            pref.setData(null)
 | 
				
			||||||
| 
						 | 
					@ -260,7 +263,7 @@ export default class UserRelatedState {
 | 
				
			||||||
        })
 | 
					        })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (const key in Constants.userJourney) {
 | 
					        for (const key in Constants.userJourney) {
 | 
				
			||||||
            amendedPrefs.data["__userjourney_"+key] = Constants.userJourney[key]
 | 
					            amendedPrefs.data["__userjourney_" + key] = Constants.userJourney[key]
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const osmConnection = this.osmConnection
 | 
					        const osmConnection = this.osmConnection
 | 
				
			||||||
| 
						 | 
					@ -291,13 +294,13 @@ export default class UserRelatedState {
 | 
				
			||||||
                    const zenLinks: { link: string; id: string }[] = Utils.NoNull([
 | 
					                    const zenLinks: { link: string; id: string }[] = Utils.NoNull([
 | 
				
			||||||
                        hasMissingTheme
 | 
					                        hasMissingTheme
 | 
				
			||||||
                            ? {
 | 
					                            ? {
 | 
				
			||||||
                                  id: "theme:" + layout.id,
 | 
					                                id: "theme:" + layout.id,
 | 
				
			||||||
                                  link: LinkToWeblate.hrefToWeblateZen(
 | 
					                                link: LinkToWeblate.hrefToWeblateZen(
 | 
				
			||||||
                                      language,
 | 
					                                    language,
 | 
				
			||||||
                                      "themes",
 | 
					                                    "themes",
 | 
				
			||||||
                                      layout.id
 | 
					                                    layout.id
 | 
				
			||||||
                                  ),
 | 
					                                ),
 | 
				
			||||||
                              }
 | 
					                            }
 | 
				
			||||||
                            : undefined,
 | 
					                            : undefined,
 | 
				
			||||||
                        ...missingLayers.map((id) => ({
 | 
					                        ...missingLayers.map((id) => ({
 | 
				
			||||||
                            id: "layer:" + id,
 | 
					                            id: "layer:" + id,
 | 
				
			||||||
| 
						 | 
					@ -369,7 +372,7 @@ export default class UserRelatedState {
 | 
				
			||||||
                    // Language is managed seperately
 | 
					                    // Language is managed seperately
 | 
				
			||||||
                    continue
 | 
					                    continue
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                this.osmConnection.GetPreference(key, undefined, { prefix: "" }).setData(tags[key])
 | 
					                this.osmConnection.GetPreference(key, undefined, {prefix: ""}).setData(tags[key])
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        })
 | 
					        })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue