From af7c1905c185949c736ebbcc888d7d3e8e936002 Mon Sep 17 00:00:00 2001 From: kejun Date: Tue, 21 Mar 2023 09:05:04 +0800 Subject: [PATCH] fix: first useDB is not reactivity --- components/tool/ToolDetail.vue | 2 +- composables/useHistory.ts | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/components/tool/ToolDetail.vue b/components/tool/ToolDetail.vue index 0a1d735..3458b3f 100644 --- a/components/tool/ToolDetail.vue +++ b/components/tool/ToolDetail.vue @@ -39,7 +39,7 @@ defineExpose({
- + ; +const history = ref([]); const currentHistoryId = ref(""); -// TODO: fix first useIDB export const useHistory = (_tool: MaybeRef) => { _history = useIDBKeyval( `${STORAGE_KEY_TOOL_HISTORY}${unref(_tool).id}`, [], { deep: true, + flush: "sync", } ); - const history = computed(() => _history.value); + const stop = watchEffect(() => { + history.value = _history.value; + }); + + tryOnScopeDispose(stop); function create(context: OpenAIMessages) { currentHistoryId.value = uuidv4();