Skip to content

Commit

Permalink
fix: first useDB is not reactivity
Browse files Browse the repository at this point in the history
  • Loading branch information
KeJunMao committed Mar 21, 2023
1 parent 8f977b2 commit af7c190
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion components/tool/ToolDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ defineExpose({
<div flex flex-col style="height: calc(100vh - 125px)">
<el-scrollbar height="100%">
<div p-4 sm:p-10>
<ToolResult v-if="!tool.chat" flex-1 :html="resultHtml" />
<ToolResult v-if="!tool.chat" :html="resultHtml" />
<ToolChatResult
v-else
:contexts="contexts"
Expand Down
9 changes: 7 additions & 2 deletions composables/useHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,22 @@ export interface HistoryItem {
}

let _history: RemovableRef<HistoryItem[]>;
const history = ref<HistoryItem[]>([]);
const currentHistoryId = ref("");
// TODO: fix first useIDB
export const useHistory = (_tool: MaybeRef<ToolItem>) => {
_history = useIDBKeyval<HistoryItem[]>(
`${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();
Expand Down

0 comments on commit af7c190

Please sign in to comment.