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 a3f9e91 commit c4eef3b
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 @@ -59,13 +59,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 c4eef3b

Please sign in to comment.