Skip to content

Commit

Permalink
Save prev data id to prevent double effects
Browse files Browse the repository at this point in the history
  • Loading branch information
jesperengstrom committed Dec 18, 2024
1 parent c6b3450 commit 8f8cb5a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/supersearch/src/lib/components/SuperSearch.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,15 @@
transformFn
});
let prevSearchDataId: string | undefined;
const sendMessage = StateEffect.define<{ message: string }>({});
const newDataMessage = { effects: sendMessage.of({ message: messages.NEW_DATA }) };
$effect(() => {
if (search.data) {
if (search.data && search.data?.['@id'] !== prevSearchDataId) {
expandedEditorView?.dispatch(newDataMessage);
collapsedEditorView?.dispatch(newDataMessage);
prevSearchDataId = search.data?.['@id'];
}
});
Expand Down

0 comments on commit 8f8cb5a

Please sign in to comment.