Merge branch 'master' into develop

This commit is contained in:
Pieter Vander Vennet 2025-02-05 01:26:28 +01:00
commit b0140bc7d9
2 changed files with 9 additions and 6 deletions

View file

@ -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))

View file

@ -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
}