Skip to content

Commit

Permalink
fix: fetch recents only on client
Browse files Browse the repository at this point in the history
  • Loading branch information
logotip4ik committed Nov 8, 2024
1 parent 4f66ae9 commit 6607ae5
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions app/components/Workspace/Toolbox/Recent/ToolboxRecent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ let pollingTimer: ReturnType<typeof setTimeout> | undefined;
let retryingToast: ToastInstance | undefined;
async function fetchRecent(retry: number = 0): Promise<void> {
if (import.meta.server) {
return;
}
clearTimeout(pollingTimer);
$fetch('/api/recent')
Expand Down Expand Up @@ -53,16 +57,14 @@ async function fetchRecent(retry: number = 0): Promise<void> {
});
};
const stop = watchEffect(() => {
if (state.value === 'hidden') {
const stop = watch(state, (state) => {
if (state === 'hidden') {
return;
}
fetchRecent();
nextTick(() => {
stop();
});
});
nextTick(() => stop());
}, { immediate: import.meta.client });
</script>

<template>
Expand Down

0 comments on commit 6607ae5

Please sign in to comment.