+
+ {{ $t("home.recent") }}
+
+ -
+
+ {{ p.icon }}
+
+
+ {{ p.title || $t("home.untitled") }}
+ {{ p.spaceName }}
+
+
+
+
+
+
{{ $t("sidebar.spaces") }}
import type { Page } from "@docwell/api-client";
import { CollabProvider, DocwellEditor, userColor } from "@docwell/editor";
-import { DwBreadcrumbs, DwButton, DwCallout } from "@docwell/ui";
+import { DwBreadcrumbs, DwButton, DwCallout, DwIcon } from "@docwell/ui";
import { computed, onBeforeUnmount, ref, shallowRef, watch } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
@@ -11,6 +11,7 @@ import PageHistory from "../../components/PageHistory.vue";
import PageList from "../../components/PageList.vue";
import { useRuntimeConfig } from "../../platform";
import { useAuthStore } from "../../stores/auth";
+import { useFavoritesStore } from "../../stores/favorites";
import { spaceAtLeast, useSpacesStore } from "../../stores/spaces";
import { useWorkspacesStore } from "../../stores/workspaces";
@@ -18,6 +19,7 @@ const props = defineProps<{ id: string }>();
const emit = defineEmits<{ error: [err: unknown] }>();
const api = useApi();
const spaces = useSpacesStore();
+const favorites = useFavoritesStore();
const workspaces = useWorkspacesStore();
const router = useRouter();
const { t } = useI18n();
@@ -102,6 +104,8 @@ async function load(id: string) {
// A link from another workspace switches the sidebar to it.
if (workspaces.current && p.workspace !== workspaces.current.id) workspaces.select(p.workspace);
spaces.reveal(p.space, p.id);
+ // Best effort: the recent list is a convenience.
+ api.pages.visit(p.id).catch(() => {});
} catch {
page.value = null;
notFound.value = true;
@@ -119,6 +123,7 @@ async function saveTitle() {
const saved = await api.pages.update(p.id, { title: title.value });
if (page.value?.id === saved.id) page.value = { ...page.value, title: saved.title, updated: saved.updated };
spaces.setTitle(saved.space, saved.id, saved.title);
+ favorites.setTitle(saved.id, saved.title);
} catch (e) {
emit("error", e);
}
@@ -157,6 +162,13 @@ async function run(action: () => Promise) {
}
}
+const toggleFavorite = () =>
+ run(async () => {
+ const p = page.value!;
+ await favorites.set(p.id, !p.favorite);
+ if (page.value?.id === p.id) page.value = { ...page.value, favorite: !p.favorite };
+ });
+
const addChild = () =>
run(async () => {
const child = await spaces.createPage(page.value!.space, page.value!.id);
@@ -204,6 +216,18 @@ const purge = () =>
}}
+