Skip to content

πŸ“š The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.

Improve performances, reactivity, empty states

Smaug673912b90b468a38
diff --git a/frontend/app/components/DocumentsGrid.vue b/frontend/app/components/DocumentsGrid.vue
index bd005b91..15bb4d38 100644
--- a/frontend/app/components/DocumentsGrid.vue
+++ b/frontend/app/components/DocumentsGrid.vue
@@ -1,11 +1,6 @@
<template>
<div class="document-list">
<DocumentCard v-for="document in documents" :key="document.id" :document="document" />
- <div v-if="!documents.length" style="width: 100%; height: 100%">
- <div style="margin: 10vh auto; text-align: center">
- <h1>No documents found</h1>
- </div>
- </div>
</div>
</template>
diff --git a/frontend/app/components/NoContent.vue b/frontend/app/components/NoContent.vue
new file mode 100644
index 00000000..f5bbfd90
--- /dev/null
+++ b/frontend/app/components/NoContent.vue
@@ -0,0 +1,13 @@
+<template>
+ <div style="text-align: center; margin: 5vh auto">
+ <h1>{{ title || 'Nothing here' }}</h1>
+ <img style="max-width: 300px; max-height: 300px" :src="`/empty-${colorMode.value}.png`" />
+ <p>{{ description }}</p>
+ <slot />
+ </div>
+</template>
+
+<script setup lang="ts">
+const colorMode = useColorMode();
+defineProps<{ title?: string; description?: string }>();
+</script>
diff --git a/frontend/app/components/Sidebar/Sidebar.vue b/frontend/app/components/Sidebar/Sidebar.vue
index 9f33940d..679b319d 100644
--- a/frontend/app/components/Sidebar/Sidebar.vue
+++ b/frontend/app/components/Sidebar/Sidebar.vue
@@ -30,7 +30,12 @@
<SidebarWorkspaces :options="workspaces" />
<CollapseItem v-for="item in navigationItems" :key="item.id" :item="item" :root="true" />
<hr style="width: 100%; margin: 5px 0" />
- <CollapseItem v-for="item in tree" :key="item.id" :item="item" :root="true" />
+ <template v-if="tree.length">
+ <CollapseItem v-for="item in tree" :key="item.id" :item="item" :root="true" />
+ </template>
+ <template v-else>
+ <SidebarSkeleton :is-loading="isLoading" />
+ </template>
</div>
</Resizable>
</template>
@@ -40,16 +45,19 @@ import CollapseItem from './CollapseItem.vue';
import SidebarWorkspaces from './SidebarWorkspaces.vue';
import Resizable from './Resizable.vue';
import IconClose from './IconClose.vue';
+import SidebarSkeleton from './SidebarSkeleton.vue';
import { navigationItems } from './helpers';
import NewCategoryModal from '@/pages/dashboard/categories/_modals/CreateCategoryModal.vue';
import Dock from './Dock.vue';
const { isOpened, hasSidebar } = useSidebar();
const categoriesStore = useCategoriesStore();
+const documentsStore = useDocumentsStore();
const preferences = usePreferences();
const userStore = useUserStore();
const filter = ref<string>('');
-const workspaces = computed(() => [...categoriesStore.categories.filter(c => c.role === 2).map(c => ({ text: c.name, value: c.id, meta: c }))]);
+const workspaces = computed(() => [...categoriesStore.getAll.filter(c => c.role === 2).map(c => ({ text: c.name, value: c.id, meta: c }))]);
+const isLoading = computed(() => categoriesStore.isFetching || documentsStore.isFetching);
const sidebarTree = useSidebarTree();
const toggleDock = () => preferences.set('view_dock', !preferences.get('view_dock'));
diff --git a/frontend/app/components/Sidebar/SidebarSkeleton.vue b/frontend/app/components/Sidebar/SidebarSkeleton.vue
new file mode 100644
index 00000000..6bfe771f
--- /dev/null
+++ b/frontend/app/components/Sidebar/SidebarSkeleton.vue
@@ -0,0 +1,91 @@
+<template>
+ <div style="width: 100%; height: 100%">
+ <div v-if="isLoading" class="sidebar-skeleton">
+ <div v-for="n in 30" :key="n" class="skeleton-line" :style="{ marginRight: `${(n % 3) * 22}px` }" />
+ </div>
+ <div v-else class="empty-sidebar">
+ <div class="icon">
+ <svg fill="var(--font-color-light)" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
+ <g id="SVGRepo_bgCarrier" stroke-width="0"></g>
+ <g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g>
+ <g id="SVGRepo_iconCarrier">
+ <path
+ stroke-width="0"
+ d="M3 20h18a1 1 0 0 0 .864-1.504l-7-12c-.359-.615-1.369-.613-1.729 0L9.866 12.1l-1.02-1.632A.998.998 0 0 0 8 10h-.001a1 1 0 0 0-.847.47l-5 8A1 1 0 0 0 3 20zM14 8.985 19.259 18h-5.704l-2.486-3.987L14 8.985zm-5.999 3.9L11.197 18H4.805l3.196-5.115zM6 8c1.654 0 3-1.346 3-3S7.654 2 6 2 3 3.346 3 5s1.346 3 3 3zm0-4a1 1 0 1 1 0 2 1 1 0 0 1 0-2z"
+ ></path>
+ </g>
+ </svg>
+ </div>
+ <p class="message">No content available</p>
+ <small class="hint">Create a new document or category to get started</small>
+ <span class="action-link">Create New</span>
+ </div>
+ </div>
+</template>
+
+<script setup lang="ts">
+defineProps<{ isLoading: boolean }>();
+</script>
+
+<style scoped lang="scss">
+.sidebar-skeleton {
+ display: flex;
+ flex-direction: column;
+ gap: 6px;
+ margin-top: 8px;
+ padding: 2rem;
+}
+
+.skeleton-line {
+ height: 22px;
+ border-radius: 6px;
+ background: linear-gradient(90deg, var(--bg-contrast) 25%, var(--bg-color) 37%, var(--bg-contrast) 63%);
+ background-size: 400% 100%;
+ animation: shimmer 1.4s ease infinite;
+}
+
+@keyframes shimmer {
+ 0% {
+ background-position: 200% 0;
+ }
+ 100% {
+ background-position: -200% 0;
+ }
+}
+
+.empty-sidebar {
+ height: 100%;
+ display: flex;
+ flex-direction: column;
+ padding: 20% 1rem;
+ color: var(--font-color-light);
+ text-align: center;
+}
+
+.empty-sidebar .icon {
+ margin-bottom: 1rem;
+ svg {
+ width: 100px;
+ height: 100px;
+ stroke: var(--font-color-light);
+ }
+}
+
+.empty-sidebar .message {
+ font-size: 0.95rem;
+ font-weight: 500;
+ margin-bottom: 0.25rem;
+}
+
+.empty-sidebar .hint {
+ font-size: 0.75rem;
+ color: var(--font-color-muted);
+}
+.action-link {
+ margin-top: 5px;
+ font-size: 0.75rem;
+ font-weight: bold;
+ color: var(--primary);
+ cursor: pointer;
+}
+</style>
diff --git a/frontend/app/components/Sidebar/SidebarWorkspaces.vue b/frontend/app/components/Sidebar/SidebarWorkspaces.vue
index 77cd17a3..10bd6e04 100644
--- a/frontend/app/components/Sidebar/SidebarWorkspaces.vue
+++ b/frontend/app/components/Sidebar/SidebarWorkspaces.vue
@@ -29,12 +29,19 @@ import NewCategoryModal from '@/pages/dashboard/categories/_modals/CreateCategor
import type { Workspace } from './helpers';
const { workspaceId } = useSidebar();
-const storage_item = localStorage.getItem('filterWorkspace');
const props = defineProps<{ options: Workspace[] }>();
const all_workspaces = ref({ text: 'All Workspaces', value: null, meta: { color: -1 } });
-if (storage_item && props.options.find(option => option.value == storage_item)) workspaceId.value = storage_item;
-
+watch(
+ () => props.options,
+ opts => {
+ const storage_item = localStorage.getItem('filterWorkspace');
+ if (storage_item && opts.find(option => option.value == storage_item)) {
+ workspaceId.value = storage_item;
+ }
+ },
+ { immediate: true }, // check also during mounting
+);
const isOpen = ref(false);
const selectedOption = computed(() => props.options.find(option => option.value == workspaceId.value) || all_workspaces.value);
const toggleDropdown = () => (isOpen.value = !isOpen.value);
diff --git a/frontend/app/pages/dashboard.vue b/frontend/app/pages/dashboard.vue
index 5e70ec5a..431edfb5 100644
--- a/frontend/app/pages/dashboard.vue
+++ b/frontend/app/pages/dashboard.vue
@@ -8,11 +8,14 @@
<QuickSearch />
<MediumView>
<Navbar />
- <div style=" width: 100%;height: calc(100% - 65px)"><NuxtPage /></div>
+ <div style="width: 100%; height: calc(100% - 65px)"><NuxtPage /></div>
</MediumView>
</div>
</template>
<script setup lang="ts">
definePageMeta({ breadcrumb: 'Home' });
-await Promise.all([useDocumentsStore().fetch(), useCategoriesStore().fetch(), useUserStore().fetch(), useRessourcesStore().fetch()]);
+useDocumentsStore().fetch();
+useCategoriesStore().fetch();
+useUserStore().fetch();
+useRessourcesStore().fetch();
</script>
diff --git a/frontend/app/pages/dashboard/categories/[id]/index.vue b/frontend/app/pages/dashboard/categories/[id]/index.vue
index a78e2275..22454500 100644
--- a/frontend/app/pages/dashboard/categories/[id]/index.vue
+++ b/frontend/app/pages/dashboard/categories/[id]/index.vue
@@ -7,12 +7,22 @@
<ViewSelection v-model="view" />
</div>
</header>
- <div v-if="view == 'table'" class="line-container">
- <DocumentLine v-for="document of documents" :key="document.id" :document="document" class="line-item" />
- </div>
- <div v-else class="document-list">
- <DocumentsGrid :documents="documents" />
+ <div v-if="documents.length">
+ <div v-if="view == 'table'" class="line-container">
+ <DocumentLine v-for="document of documents" :key="document.id" :document="document" class="line-item" />
+ </div>
+ <div v-else class="document-list">
+ <DocumentsGrid :documents="documents" />
+ </div>
</div>
+ <NoContent
+ v-else
+ style="width: 100%; height: 100%"
+ title="No documents found"
+ description="There are no documents in this category
+"
+ ><NuxtLink to="/dashboard/docs/new"><AppButton type="link" style="font-weight: bold">+ Create new document </AppButton></NuxtLink>
+ </NoContent>
</div>
</template>
diff --git a/frontend/app/pages/dashboard/cdn/index.vue b/frontend/app/pages/dashboard/cdn/index.vue
index bf721d22..63cf6110 100644
--- a/frontend/app/pages/dashboard/cdn/index.vue
+++ b/frontend/app/pages/dashboard/cdn/index.vue
@@ -27,7 +27,7 @@
</template>
</DataTable>
</div>
- <div v-else>No ressource found.</div>
+ <NoContent v-else title="No ressource found"></NoContent>
</div>
</template>
<script setup lang="ts">
diff --git a/frontend/app/pages/dashboard/docs/[id].vue b/frontend/app/pages/dashboard/docs/[id].vue
index 6c975376..0d640f62 100644
--- a/frontend/app/pages/dashboard/docs/[id].vue
+++ b/frontend/app/pages/dashboard/docs/[id].vue
@@ -1,28 +1,34 @@
<template>
- <div v-if="article?.id" style="width: 100%; padding: 1rem 0">
- <div style="display: flex; justify-content: space-between">
+ <div style="width: 100%; padding: 1rem 0">
+ <div v-if="!error" style="display: flex; justify-content: space-between">
<div :style="{ maxWidth: usePreferences().get('docSize') == 0 ? '980px' : '810px' }" class="doc-container">
<DocumentCardHeader :doc="article" style="margin-bottom: 20px" />
+
<!-- eslint-disable-next-line vue/no-v-html -->
- <article ref="element" :class="`${usePreferences().get('theme')}-theme`" style="max-width: 100%" v-html="article.content_html" />
+ <article v-if="article" ref="element" :class="`${usePreferences().get('theme')}-theme`" style="max-width: 100%" v-html="article.content_html" />
+ <DocumentSkeleton v-else />
<DocumentCardFooter :document="article" :next="next" :previous="previous" />
</div>
+
<div v-if="!isTablet() && !preferencesStore.get('hideTOC')" class="toc">
<TableOfContent :doc="article" :element="element" style="width: 350px" />
</div>
+
<div
- :style="{ marginRight: !isTablet() && preferencesStore.get('hideTOC') && useSidebar().isOpened.value ? '200px' : '0px', transition: 'margin 0.3s' }"
+ :style="{ marginRight: !isTablet() && !preferencesStore.get('hideTOC') && useSidebar().isOpened.value ? '200px' : '0px', transition: 'margin 0.3s' }"
/>
</div>
+ <Error v-else :error="error" />
</div>
- <Error v-else-if="error" :error="error" />
</template>
-
<script setup lang="ts">
-import type { Document } from '@/stores';
import TableOfContent from './_components/table-of-content/TableOfContents.vue';
import DocumentCardHeader from './_components/DocumentCardHeader.vue';
import DocumentCardFooter from './_components/DocumentCardFooter.vue';
+import DocumentSkeleton from './_components/DocumentSkeleton.vue';
+
+import type { Document } from '@/stores';
+
const route = useRoute();
const documentsStore = useDocumentsStore();
const preferencesStore = usePreferences();
@@ -35,6 +41,7 @@ watchEffect(async () => {
const document_id = route.params.id as string;
const docFromStore = documentsStore.getById(document_id);
if (!docFromStore) {
+ if (documentsStore.isFetching) return;
return (error.value = 'Document not found');
}
article.value = undefined;
@@ -65,11 +72,13 @@ const previous = computed(() => documentsStore.getPrevious(article.value));
width: 100%;
margin: 0 auto;
}
+
@media screen and (width >= 810px) {
.doc-container {
padding: 0 2rem;
}
}
+
.toc {
position: relative;
}
diff --git a/frontend/app/pages/dashboard/docs/_components/DocumentCardFooter.vue b/frontend/app/pages/dashboard/docs/_components/DocumentCardFooter.vue
index 44d3bca0..dcd9f18a 100644
--- a/frontend/app/pages/dashboard/docs/_components/DocumentCardFooter.vue
+++ b/frontend/app/pages/dashboard/docs/_components/DocumentCardFooter.vue
@@ -1,5 +1,5 @@
<template>
- <footer>
+ <footer v-if="document">
<div class="infos">
<NuxtLink :to="`/dashboard/docs/edit/${document.id}`" :prefetch="false"><Icon name="edit_page" /> Edit this page</NuxtLink>
<p>Last update: {{ new Date(parseInt(document.updated_timestamp)).toLocaleDateString() }}</p>
@@ -19,7 +19,7 @@
<script lang="ts" setup>
import type { Document } from '~/stores';
-defineProps<{ document: Document; next?: Document; previous?: Document }>();
+defineProps<{ document?: Document; next?: Document; previous?: Document }>();
</script>
<style scoped lang="scss">
diff --git a/frontend/app/pages/dashboard/docs/_components/DocumentCardHeader.vue b/frontend/app/pages/dashboard/docs/_components/DocumentCardHeader.vue
index 2593e2de..c29a3620 100644
--- a/frontend/app/pages/dashboard/docs/_components/DocumentCardHeader.vue
+++ b/frontend/app/pages/dashboard/docs/_components/DocumentCardHeader.vue
@@ -1,15 +1,20 @@
<template>
<div class="header" :class="{ 'print-style': preferences.get('printMode') }">
<div class="text">
- <p class="category">
- <NuxtLink :to="`/dashboard/categories/${category?.id}`">{{ category?.name }}</NuxtLink>
- <DocumentCardHeaderActionRow :doc="doc" class="no-print" />
- </p>
- <h1 class="title">{{ doc?.name }}</h1>
- <p class="description">{{ doc?.description }}</p>
- <div v-if="doc.tags" class="document-tags">
- <tag v-for="tag in doc.tags.split(',')" :key="tag" class="primary">{{ tag.trim() }}</tag>
- </div>
+ <!-- Skeleton when doc is undefined -->
+ <DocumentCardHeaderSkeleton v-if="!doc" />
+ <!-- Real content -->
+ <template v-else>
+ <p class="category">
+ <NuxtLink :to="`/dashboard/categories/${category?.id}`">{{ category?.name }}</NuxtLink>
+ <DocumentCardHeaderActionRow :doc="doc" class="no-print" />
+ </p>
+ <h1 class="title">{{ doc?.name }}</h1>
+ <p class="description">{{ doc?.description }}</p>
+ <div v-if="doc.tags" class="document-tags">
+ <tag v-for="tag in doc.tags.split(',')" :key="tag" class="primary">{{ tag.trim() }}</tag>
+ </div>
+ </template>
</div>
<div class="icon">
<DocumentHeaderIllustration />
@@ -20,10 +25,12 @@
<script setup lang="ts">
import DocumentCardHeaderActionRow from './DocumentCardHeaderActionRow.vue';
import DocumentHeaderIllustration from './DocumentHeaderIllustration.vue';
+import DocumentCardHeaderSkeleton from './DocumentCardHeaderSkeleton.vue';
import type { Document } from '~/stores';
+
const categories_store = useCategoriesStore();
const preferences = usePreferences();
-const props = defineProps<{ doc: Document }>();
+const props = defineProps<{ doc?: Document }>();
const category = computed(() => categories_store.getById(props.doc?.category || ''));
</script>
@@ -76,6 +83,45 @@ p {
padding-top: 5px;
}
+/* --- Skeleton Loader --- */
+.skeleton {
+ background: linear-gradient(90deg, #ddd 25%, #eee 37%, #ddd 63%);
+ background-size: 400% 100%;
+ animation: shimmer 1.4s ease infinite;
+ border-radius: 6px;
+ margin: 8px 0;
+}
+.skeleton-category {
+ width: 40%;
+ height: 20px;
+}
+.skeleton-title {
+ width: 70%;
+ height: 28px;
+}
+.skeleton-desc {
+ width: 90%;
+ height: 16px;
+}
+.skeleton-tag {
+ display: inline-block;
+ width: 80px;
+ height: 20px;
+ margin-right: 6px;
+}
+.skeleton-tag.short {
+ width: 50px;
+}
+
+@keyframes shimmer {
+ 0% {
+ background-position: -400px 0;
+ }
+ 100% {
+ background-position: 400px 0;
+ }
+}
+
@media print, screen and (width >= 1024px) {
.icon {
display: block;
diff --git a/frontend/app/pages/dashboard/docs/_components/DocumentCardHeaderSkeleton.vue b/frontend/app/pages/dashboard/docs/_components/DocumentCardHeaderSkeleton.vue
new file mode 100644
index 00000000..ac8a5407
--- /dev/null
+++ b/frontend/app/pages/dashboard/docs/_components/DocumentCardHeaderSkeleton.vue
@@ -0,0 +1,80 @@
+<template>
+ <div>
+ <div class="skeleton skeleton-category"></div>
+ <div class="skeleton skeleton-title"></div>
+ <div class="skeleton skeleton-desc"></div>
+ <div class="skeleton skeleton-tag"></div>
+ <div class="skeleton skeleton-tag short"></div>
+ </div>
+</template>
+
+<style scoped lang="scss">
+/* --- Skeleton Loader --- */
+.skeleton {
+ background: linear-gradient(90deg, #ddd 25%, #eee 37%, #ddd 63%);
+ background-size: 400% 100%;
+ animation: shimmer 1.4s ease infinite;
+ border-radius: 6px;
+ margin: 8px 0;
+}
+.skeleton-category {
+ width: 40%;
+ height: 20px;
+ margin: 10px 0;
+}
+.skeleton-title {
+ width: 70%;
+ height: 41px;
+ margin: 15px 0;
+}
+.skeleton-desc {
+ width: 90%;
+ height: 16px;
+}
+.skeleton-tag {
+ display: inline-block;
+ width: 80px;
+ height: 20px;
+ margin-right: 6px;
+}
+.skeleton-tag.short {
+ width: 50px;
+}
+
+@keyframes shimmer {
+ 0% {
+ background-position: -400px 0;
+ }
+ 100% {
+ background-position: 400px 0;
+ }
+}
+
+@media print, screen and (width >= 1024px) {
+ .icon {
+ display: block;
+ }
+}
+
+@media print {
+ .print-style {
+ padding: 0.4rem 0.2rem;
+ background: none;
+ align-items: center;
+
+ .icon,
+ .description,
+ .document-tags,
+ .category {
+ display: none;
+ }
+
+ .title {
+ font-size: 27px;
+ font-weight: 700;
+ text-align: center;
+ border-bottom: 1px solid var(--font-color);
+ }
+ }
+}
+</style>
diff --git a/frontend/app/pages/dashboard/docs/_components/DocumentSkeleton.vue b/frontend/app/pages/dashboard/docs/_components/DocumentSkeleton.vue
new file mode 100644
index 00000000..f14b8282
--- /dev/null
+++ b/frontend/app/pages/dashboard/docs/_components/DocumentSkeleton.vue
@@ -0,0 +1,60 @@
+<template>
+ <div class="article-skeleton">
+ <div class="skeleton-paragraph">
+ <div class="skeleton-line" style="width: 90%"></div>
+ <div class="skeleton-line" style="width: 100%"></div>
+ <div class="skeleton-line" style="width: 85%"></div>
+ </div>
+ <div class="skeleton-paragraph">
+ <div class="skeleton-line" style="width: 95%"></div>
+ <div class="skeleton-line" style="width: 80%"></div>
+ <div class="skeleton-line" style="width: 100%"></div>
+ <div class="skeleton-line" style="width: 100%"></div>
+ <div class="skeleton-line" style="width: 100%"></div>
+ <div class="skeleton-line" style="width: 100%"></div>
+ <div class="skeleton-line" style="width: 60%"></div>
+ </div>
+ <div class="skeleton-paragraph">
+ <div class="skeleton-line" style="width: 100%"></div>
+ <div class="skeleton-line" style="width: 95%"></div>
+ <div class="skeleton-line" style="width: 70%"></div>
+ <div class="skeleton-line" style="width: 100%"></div>
+ <div class="skeleton-line" style="width: 100%"></div>
+ <div class="skeleton-line" style="width: 100%"></div>
+
+ <div class="skeleton-line" style="width: 80%"></div>
+ </div>
+ </div>
+</template>
+
+<style scoped lang="scss">
+.article-skeleton {
+ display: flex;
+ flex-direction: column;
+ gap: 50px;
+ padding: 2rem 0;
+}
+
+.skeleton-paragraph {
+ display: flex;
+ flex-direction: column;
+ gap: 8px;
+}
+
+.skeleton-line {
+ height: 22px;
+ border-radius: 4px;
+ background: linear-gradient(90deg, #ddd 25%, #eee 37%, #ddd 63%);
+ background-size: 200% 100%;
+ animation: skeleton-loading 1.5s infinite;
+}
+
+@keyframes skeleton-loading {
+ from {
+ background-position: 200% 0;
+ }
+ to {
+ background-position: -200% 0;
+ }
+}
+</style>
diff --git a/frontend/app/pages/dashboard/docs/index.vue b/frontend/app/pages/dashboard/docs/index.vue
index b9f6b604..73173ca4 100644
--- a/frontend/app/pages/dashboard/docs/index.vue
+++ b/frontend/app/pages/dashboard/docs/index.vue
@@ -4,12 +4,15 @@
<h1>Documents <tag blue>New</tag></h1>
<ViewSelection v-model="view" />
</header>
- <div v-if="view == 'table'" class="line-container">
- <DocumentLine v-for="document of documents" :key="document.id" :document="document" class="line-item" />
- </div>
- <div v-else class="document-list">
- <DocumentsGrid :documents="documents" />
- </div>
+ <template v-if="documents.length">
+ <div v-if="view == 'table'" class="line-container">
+ <DocumentLine v-for="document of documents" :key="document.id" :document="document" class="line-item" />
+ </div>
+ <DocumentsGrid v-else :documents="documents" />
+ </template>
+ <NoContent v-else title="No documents found" description="There are no documents here">
+ <NuxtLink to="/dashboard/docs/new"><AppButton type="link" style="font-weight: bold">Create new one </AppButton></NuxtLink>
+ </NoContent>
</div>
</template>
diff --git a/frontend/app/stores/categories.store.ts b/frontend/app/stores/categories.store.ts
index 79a2d634..1c3e75db 100644
--- a/frontend/app/stores/categories.store.ts
+++ b/frontend/app/stores/categories.store.ts
@@ -4,6 +4,7 @@ import type { Category, DB_Category } from './db_strustures';
export const useCategoriesStore = defineStore('categories', {
state: () => ({
categories: [] as Category[],
+ isFetching: false,
}),
getters: {
getAll: state => state.categories,
@@ -13,7 +14,9 @@ export const useCategoriesStore = defineStore('categories', {
},
actions: {
async fetch(opts?: FetchOptions) {
+ this.isFetching = true;
const request = await makeRequest(`categories/@me/${opts?.id || ''}`, 'GET', {});
+ this.isFetching = false;
if (request.status == 'success') {
if (opts?.id) {
// replace the document with the new one
diff --git a/frontend/app/stores/documents.store.ts b/frontend/app/stores/documents.store.ts
index b7de4f2e..10d9e4ad 100644
--- a/frontend/app/stores/documents.store.ts
+++ b/frontend/app/stores/documents.store.ts
@@ -14,6 +14,7 @@ export const useDocumentsStore = defineStore('documents', {
state: () => ({
documents: [] as Document[],
allTags: [] as string[],
+ isFetching: false,
}),
getters: {
getAll: state => state.documents,
@@ -99,7 +100,9 @@ export const useDocumentsStore = defineStore('documents', {
},
async fetch<T extends FetchOptions>(opts?: T): Promise<'id' extends keyof T ? Document : Document[]> {
console.log(`[store/documents] Fetching documents with options: ${JSON.stringify(opts)}`);
+ this.isFetching = true;
const request = await makeRequest(`documents/@me/${opts?.id || ''}`, 'GET', {});
+ this.isFetching = false;
if (request.status == 'success') {
if (opts?.id) {
const index = this.documents.findIndex(d => d.id == opts?.id);