From 440d4fbeb8855ec6c231e80f050a597f65a4529d Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Tue, 8 Apr 2025 14:51:35 +0200 Subject: [PATCH] Fix: fix some crashes for people who have used dev at the same time and have the new theme-history --- src/Logic/State/SearchState.ts | 12 +++++++++++- src/UI/BigComponents/ThemesList.svelte | 12 +++++++++++- src/UI/Search/ThemeResults.svelte | 14 ++++++++++++-- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/Logic/State/SearchState.ts b/src/Logic/State/SearchState.ts index 59b59d9bb..cb9992775 100644 --- a/src/Logic/State/SearchState.ts +++ b/src/Logic/State/SearchState.ts @@ -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] ) diff --git a/src/UI/BigComponents/ThemesList.svelte b/src/UI/BigComponents/ThemesList.svelte index 7bd9d9f6f..c53da0ac1 100644 --- a/src/UI/BigComponents/ThemesList.svelte +++ b/src/UI/BigComponents/ThemesList.svelte @@ -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) + }
@@ -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)} {#if $search && hasSelection && themes?.[0] === theme}