forked from MapComplete/MapComplete
Fix: fix some crashes for people who have used dev at the same time and have the new theme-history
This commit is contained in:
parent
8d8b34dafc
commit
440d4fbeb8
3 changed files with 34 additions and 4 deletions
|
@ -70,7 +70,17 @@ export default class SearchState {
|
|||
|
||||
const themeSearch = ThemeSearchIndex.fromState(state)
|
||||
this.themeSuggestions = this.searchTerm.mapD(
|
||||
(query) => themeSearch.data.search(query, 3),
|
||||
(query) => {
|
||||
const results = themeSearch.data.search(query, 3)
|
||||
const deduped: MinimalThemeInformation[] = []
|
||||
for (const result of results) {
|
||||
if (deduped.some(th => th.id === result.id)) {
|
||||
continue
|
||||
}
|
||||
deduped.push(result)
|
||||
}
|
||||
return deduped
|
||||
},
|
||||
[themeSearch]
|
||||
)
|
||||
|
||||
|
|
|
@ -14,6 +14,16 @@
|
|||
export let state: { osmConnection: OsmConnection }
|
||||
export let onlyIcons: boolean = false
|
||||
export let hasSelection: boolean = true
|
||||
let themesFiltered: MinimalThemeInformation[] = []
|
||||
for (const theme of themes) {
|
||||
if (!theme) {
|
||||
continue
|
||||
}
|
||||
if (themesFiltered.some(th => th.id === theme.id)) {
|
||||
continue
|
||||
}
|
||||
themesFiltered.push(theme)
|
||||
}
|
||||
</script>
|
||||
|
||||
<section class="w-full">
|
||||
|
@ -23,7 +33,7 @@
|
|||
? "flex flex-wrap items-center justify-center gap-x-2"
|
||||
: "theme-list my-2 gap-4 md:grid md:grid-flow-row md:grid-cols-2 lg:grid-cols-3"}
|
||||
>
|
||||
{#each Utils.NoNull(themes) as theme (theme.id)}
|
||||
{#each Utils.NoNull(themesFiltered) as theme (theme.id)}
|
||||
<ThemeButton {theme} {state} iconOnly={onlyIcons}>
|
||||
{#if $search && hasSelection && themes?.[0] === theme}
|
||||
<span class="thanks hidden-on-mobile" aria-hidden="true">
|
||||
|
|
|
@ -11,11 +11,21 @@
|
|||
import { TrashIcon } from "@babeard/svelte-heroicons/mini"
|
||||
import { CogIcon } from "@rgossiaux/svelte-heroicons/solid"
|
||||
import Tr from "../Base/Tr.svelte"
|
||||
import { MinimalThemeInformation } from "../../Models/ThemeConfig/ThemeConfig"
|
||||
|
||||
export let state: SpecialVisualizationState
|
||||
let searchTerm = state.searchState.searchTerm
|
||||
let recentThemes = state.userRelatedState.recentlyVisitedThemes.value.map((themes) =>
|
||||
themes.filter((th) => th !== state.theme.id).slice(0, 6)
|
||||
let recentThemes = state.userRelatedState.recentlyVisitedThemes.value.map((themes) => {
|
||||
const recent = themes.filter((th) => th !== state.theme.id).slice(0, 6)
|
||||
const deduped: MinimalThemeInformation[] = []
|
||||
for (const theme of recent) {
|
||||
if (deduped.some(th => th.id === theme.id)) {
|
||||
continue
|
||||
}
|
||||
deduped.push(theme)
|
||||
}
|
||||
return deduped
|
||||
}
|
||||
)
|
||||
let themeResults = state.searchState.themeSuggestions
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue