From 28f8ffa162139929e690a7e2f67d422d9bdb2858 Mon Sep 17 00:00:00 2001 From: thomasgross Date: Thu, 19 Dec 2024 13:06:44 +0100 Subject: [PATCH] fix: search machine to have a specific method for loading more results --- lib/machines/search/search.machine.setup.ts | 12 ++++++++++++ lib/machines/search/search.machine.ts | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/machines/search/search.machine.setup.ts b/lib/machines/search/search.machine.setup.ts index 85bee67..d67b7e7 100644 --- a/lib/machines/search/search.machine.setup.ts +++ b/lib/machines/search/search.machine.setup.ts @@ -73,6 +73,18 @@ export default setup({ }, }), setSearchDataInContext: assign({ + searchData: ({ + event: { + output: { search }, + }, + }) => { + return { + hitcount: search.hitcount, + pages: [[...search.works]], + } + }, + }), + addMoreDataInContext: assign({ searchData: ({ event: { output: { search }, diff --git a/lib/machines/search/search.machine.ts b/lib/machines/search/search.machine.ts index a9a7bbb..3427836 100644 --- a/lib/machines/search/search.machine.ts +++ b/lib/machines/search/search.machine.ts @@ -213,7 +213,7 @@ export default searchMachineSetup.createMachine({ } }, onDone: { - actions: ["setSearchDataInContext"], + actions: ["addMoreDataInContext"], target: "#search.idle", }, onError: {},