mirror of
https://github.com/docmost/docmost.git
synced 2025-11-20 23:41:08 +10:00
fix: sidebar list when changing workspace (#1150)
* init * navigate in overview if current page is in deleted node * fix: implement pagination in sidebar-pages queries * fix: appendNodeChildren() Preserve deeper children if they exist and remove node if deleted
This commit is contained in:
@ -10,6 +10,7 @@ import {
|
||||
} from "@/features/page/types/page.types";
|
||||
import { IAttachment, IPagination } from "@/lib/types.ts";
|
||||
import { saveAs } from "file-saver";
|
||||
import { InfiniteData } from "@tanstack/react-query";
|
||||
|
||||
export async function createPage(data: Partial<IPage>): Promise<IPage> {
|
||||
const req = await api.post<IPage>("/pages/create", data);
|
||||
@ -52,6 +53,32 @@ export async function getSidebarPages(
|
||||
return req.data;
|
||||
}
|
||||
|
||||
export async function getAllSidebarPages(
|
||||
params: SidebarPagesParams,
|
||||
): Promise<InfiniteData<IPagination<IPage>, unknown>> {
|
||||
let page = 1;
|
||||
let hasNextPage = false;
|
||||
const pages: IPagination<IPage>[] = [];
|
||||
const pageParams: number[] = [];
|
||||
|
||||
do {
|
||||
const req = await api.post("/pages/sidebar-pages", { ...params, page: page });
|
||||
|
||||
const data: IPagination<IPage> = req.data;
|
||||
pages.push(data);
|
||||
pageParams.push(page);
|
||||
|
||||
hasNextPage = data.meta.hasNextPage;
|
||||
|
||||
page += 1;
|
||||
} while (hasNextPage);
|
||||
|
||||
return {
|
||||
pageParams,
|
||||
pages,
|
||||
};
|
||||
}
|
||||
|
||||
export async function getPageBreadcrumbs(
|
||||
pageId: string,
|
||||
): Promise<Partial<IPage[]>> {
|
||||
|
||||
Reference in New Issue
Block a user