diff --git a/apps/client/src/features/search/components/search-spotlight-filters.tsx b/apps/client/src/features/search/components/search-spotlight-filters.tsx index 87e03c7e..f19d413e 100644 --- a/apps/client/src/features/search/components/search-spotlight-filters.tsx +++ b/apps/client/src/features/search/components/search-spotlight-filters.tsx @@ -18,7 +18,6 @@ import { IconFileDescription, IconSearch, IconCheck, - IconSparkles, } from "@tabler/icons-react"; import { useTranslation } from "react-i18next"; import { useDebouncedValue } from "@mantine/hooks"; @@ -26,7 +25,7 @@ import { useGetSpacesQuery } from "@/features/space/queries/space-query"; import { useLicense } from "@/ee/hooks/use-license"; import classes from "./search-spotlight-filters.module.css"; import { isCloud } from "@/lib/config.ts"; -import { useAtom } from "jotai/index"; +import { useAtom } from "jotai"; import { workspaceAtom } from "@/features/user/atoms/current-user-atom.ts"; interface SearchSpotlightFiltersProps { @@ -53,7 +52,6 @@ export function SearchSpotlightFilters({ const [workspace] = useAtom(workspaceAtom); const { data: spacesData } = useGetSpacesQuery({ - page: 1, limit: 100, query: debouncedSpaceQuery, }); @@ -265,7 +263,9 @@ export function SearchSpotlightFilters({ contentType !== option.value && handleFilterChange("contentType", option.value) } - disabled={option.disabled || (isAiMode && option.value === "attachment")} + disabled={ + option.disabled || (isAiMode && option.value === "attachment") + } >
@@ -275,11 +275,13 @@ export function SearchSpotlightFilters({ {t("Enterprise")} )} - {!option.disabled && isAiMode && option.value === "attachment" && ( - - {t("Ask AI not available for attachments")} - - )} + {!option.disabled && + isAiMode && + option.value === "attachment" && ( + + {t("Ask AI not available for attachments")} + + )}
{contentType === option.value && }
diff --git a/apps/client/src/features/space/components/space-grid.tsx b/apps/client/src/features/space/components/space-grid.tsx index c6a1bcf4..76a01ec3 100644 --- a/apps/client/src/features/space/components/space-grid.tsx +++ b/apps/client/src/features/space/components/space-grid.tsx @@ -15,7 +15,7 @@ import { AvatarIconType } from "@/features/attachments/types/attachment.types.ts export default function SpaceGrid() { const { t } = useTranslation(); - const { data, isLoading } = useGetSpacesQuery({ page: 1, limit: 10 }); + const { data, isLoading } = useGetSpacesQuery({ limit: 10 }); const cards = data?.items.slice(0, 9).map((space, index) => ( = { items: T[]; diff --git a/apps/server/src/core/page/services/page.service.ts b/apps/server/src/core/page/services/page.service.ts index aa085779..3b02e14e 100644 --- a/apps/server/src/core/page/services/page.service.ts +++ b/apps/server/src/core/page/services/page.service.ts @@ -206,7 +206,8 @@ export class PageService { return executeWithCursorPagination(query, { perPage: 250, - after: pagination.cursor, + cursor: pagination.cursor, + beforeCursor: pagination.beforeCursor, fields: [ { expression: 'position', direction: 'asc', orderModifier: (ob) => ob.collate('C').asc() }, { expression: 'id', direction: 'asc' }, diff --git a/apps/server/src/core/workspace/services/workspace-invitation.service.ts b/apps/server/src/core/workspace/services/workspace-invitation.service.ts index 60824253..90d5f7b4 100644 --- a/apps/server/src/core/workspace/services/workspace-invitation.service.ts +++ b/apps/server/src/core/workspace/services/workspace-invitation.service.ts @@ -66,7 +66,8 @@ export class WorkspaceInvitationService { return executeWithCursorPagination(query, { perPage: pagination.limit, - after: pagination.cursor, + cursor: pagination.cursor, + beforeCursor: pagination.beforeCursor, fields: [{ expression: 'id', direction: 'asc' }], parseCursor: (cursor) => ({ id: cursor.id }), }); diff --git a/apps/server/src/database/pagination/cursor-pagination.ts b/apps/server/src/database/pagination/cursor-pagination.ts index 973b4cda..8589a37a 100644 --- a/apps/server/src/database/pagination/cursor-pagination.ts +++ b/apps/server/src/database/pagination/cursor-pagination.ts @@ -110,9 +110,10 @@ type CursorPaginationResultRow< type CursorPaginationMeta = { limit: number; - hasNextPage?: boolean; - hasPrevPage?: boolean; + hasNextPage: boolean; + hasPrevPage: boolean; nextCursor: string | null; + prevCursor: string | null; }; export type CursorPaginationResult< @@ -133,8 +134,8 @@ export async function executeWithCursorPagination< qb: SelectQueryBuilder, opts: { perPage: number; - after?: string; - before?: string; + cursor?: string; + beforeCursor?: string; cursorPerRow?: TCursorKey; fields: TFields; encodeCursor?: CursorEncoder; @@ -219,10 +220,10 @@ export async function executeWithCursorPagination< }); } - if (opts.after) qb = applyCursor(qb, opts.after, 'asc'); - if (opts.before) qb = applyCursor(qb, opts.before, 'desc'); + if (opts.cursor) qb = applyCursor(qb, opts.cursor, 'asc'); + if (opts.beforeCursor) qb = applyCursor(qb, opts.beforeCursor, 'desc'); - const reversed = !!opts.before && !opts.after; + const reversed = !!opts.beforeCursor && !opts.cursor; for (const { expression, direction, orderModifier } of fields) { qb = qb.orderBy( @@ -234,8 +235,7 @@ export async function executeWithCursorPagination< const rows = await qb.limit(opts.perPage + 1).execute(); - const hasNextPage = reversed ? true : rows.length > opts.perPage; - const hasPrevPage = !reversed ? undefined : rows.length > opts.perPage; + const hasNextPage = rows.length > opts.perPage; // If we fetched an extra row to determine if we have a next page, that // shouldn't be in the returned results @@ -243,10 +243,11 @@ export async function executeWithCursorPagination< if (reversed) rows.reverse(); - //const startRow = rows[0]; + const startRow = rows[0]; const endRow = rows[rows.length - 1]; - //const startCursor = startRow ? generateCursor(startRow) : null; + const hasPrevPage = !!opts.cursor; + const prevCursor = hasPrevPage && startRow ? generateCursor(startRow) : null; const nextCursor = hasNextPage && endRow ? generateCursor(endRow) : null; return { @@ -263,8 +264,9 @@ export async function executeWithCursorPagination< meta: { limit: opts.perPage, hasNextPage, - hasPrevPage: hasPrevPage ?? !!opts.after, + hasPrevPage, nextCursor, + prevCursor, }, }; } diff --git a/apps/server/src/database/pagination/pagination-options.ts b/apps/server/src/database/pagination/pagination-options.ts index c3ac984a..49b4d3c0 100644 --- a/apps/server/src/database/pagination/pagination-options.ts +++ b/apps/server/src/database/pagination/pagination-options.ts @@ -9,11 +9,6 @@ import { } from 'class-validator'; export class PaginationOptions { - @IsOptional() - @IsNumber() - @Min(1) - page = 1; - @IsOptional() @IsNumber() @IsPositive() @@ -25,6 +20,10 @@ export class PaginationOptions { @IsString() cursor?: string; + @IsOptional() + @IsString() + beforeCursor?: string; + @IsOptional() @IsString() query: string; diff --git a/apps/server/src/database/repos/comment/comment.repo.ts b/apps/server/src/database/repos/comment/comment.repo.ts index e4b536e5..9d1a954e 100644 --- a/apps/server/src/database/repos/comment/comment.repo.ts +++ b/apps/server/src/database/repos/comment/comment.repo.ts @@ -41,7 +41,8 @@ export class CommentRepo { return executeWithCursorPagination(query, { perPage: pagination.limit, - after: pagination.cursor, + cursor: pagination.cursor, + beforeCursor: pagination.beforeCursor, fields: [{ expression: 'id', direction: 'asc' }], parseCursor: (cursor) => ({ id: cursor.id }), }); diff --git a/apps/server/src/database/repos/group/group-user.repo.ts b/apps/server/src/database/repos/group/group-user.repo.ts index 03f4f1a5..7d03957b 100644 --- a/apps/server/src/database/repos/group/group-user.repo.ts +++ b/apps/server/src/database/repos/group/group-user.repo.ts @@ -62,7 +62,8 @@ export class GroupUserRepo { const result = await executeWithCursorPagination(query, { perPage: pagination.limit, - after: pagination.cursor, + cursor: pagination.cursor, + beforeCursor: pagination.beforeCursor, fields: [{ expression: 'users.id', direction: 'asc', key: 'id' }], parseCursor: (cursor) => ({ id: cursor.id }), }); diff --git a/apps/server/src/database/repos/group/group.repo.ts b/apps/server/src/database/repos/group/group.repo.ts index 18726b03..621cb0c7 100644 --- a/apps/server/src/database/repos/group/group.repo.ts +++ b/apps/server/src/database/repos/group/group.repo.ts @@ -127,7 +127,8 @@ export class GroupRepo { const query = this.db.selectFrom(baseQuery.as('sub')).selectAll('sub'); return executeWithCursorPagination(query, { perPage: pagination.limit, - after: pagination.cursor, + cursor: pagination.cursor, + beforeCursor: pagination.beforeCursor, fields: [ { expression: 'sub.memberCount', diff --git a/apps/server/src/database/repos/page/page-history.repo.ts b/apps/server/src/database/repos/page/page-history.repo.ts index af158c9e..7152d8e3 100644 --- a/apps/server/src/database/repos/page/page-history.repo.ts +++ b/apps/server/src/database/repos/page/page-history.repo.ts @@ -69,7 +69,8 @@ export class PageHistoryRepo { return executeWithCursorPagination(query, { perPage: pagination.limit, - after: pagination.cursor, + cursor: pagination.cursor, + beforeCursor: pagination.beforeCursor, fields: [{ expression: 'id', direction: 'desc' }], parseCursor: (cursor) => ({ id: cursor.id }), }); diff --git a/apps/server/src/database/repos/page/page.repo.ts b/apps/server/src/database/repos/page/page.repo.ts index 7e713d38..b9ed90c7 100644 --- a/apps/server/src/database/repos/page/page.repo.ts +++ b/apps/server/src/database/repos/page/page.repo.ts @@ -285,7 +285,8 @@ export class PageRepo { return executeWithCursorPagination(query, { perPage: pagination.limit, - after: pagination.cursor, + cursor: pagination.cursor, + beforeCursor: pagination.beforeCursor, fields: [ { expression: 'updatedAt', direction: 'desc' }, { expression: 'id', direction: 'desc' }, @@ -307,7 +308,8 @@ export class PageRepo { return executeWithCursorPagination(query, { perPage: pagination.limit, - after: pagination.cursor, + cursor: pagination.cursor, + beforeCursor: pagination.beforeCursor, fields: [ { expression: 'updatedAt', direction: 'desc' }, { expression: 'id', direction: 'desc' }, @@ -347,7 +349,8 @@ export class PageRepo { return executeWithCursorPagination(query, { perPage: pagination.limit, - after: pagination.cursor, + cursor: pagination.cursor, + beforeCursor: pagination.beforeCursor, fields: [ { expression: 'deletedAt', direction: 'desc' }, { expression: 'id', direction: 'desc' }, diff --git a/apps/server/src/database/repos/share/share.repo.ts b/apps/server/src/database/repos/share/share.repo.ts index 87181a6e..994f054f 100644 --- a/apps/server/src/database/repos/share/share.repo.ts +++ b/apps/server/src/database/repos/share/share.repo.ts @@ -147,7 +147,8 @@ export class ShareRepo { return executeWithCursorPagination(query, { perPage: pagination.limit, - after: pagination.cursor, + cursor: pagination.cursor, + beforeCursor: pagination.beforeCursor, fields: [ { expression: 'updatedAt', direction: 'desc' }, { expression: 'id', direction: 'desc' }, diff --git a/apps/server/src/database/repos/space/space-member.repo.ts b/apps/server/src/database/repos/space/space-member.repo.ts index e4fd8bc6..0f9e78de 100644 --- a/apps/server/src/database/repos/space/space-member.repo.ts +++ b/apps/server/src/database/repos/space/space-member.repo.ts @@ -141,7 +141,8 @@ export class SpaceMemberRepo { const result = await executeWithCursorPagination(query, { perPage: pagination.limit, - after: pagination.cursor, + cursor: pagination.cursor, + beforeCursor: pagination.beforeCursor, fields: [ { expression: 'sub.isGroup', direction: 'desc', key: 'isGroup' }, { expression: 'sub.createdAt', direction: 'asc', key: 'createdAt' }, @@ -262,7 +263,8 @@ export class SpaceMemberRepo { return executeWithCursorPagination(query, { perPage: pagination.limit, - after: pagination.cursor, + cursor: pagination.cursor, + beforeCursor: pagination.beforeCursor, fields: [{ expression: 'id', direction: 'asc' }], parseCursor: (cursor) => ({ id: cursor.id }), }); diff --git a/apps/server/src/database/repos/space/space.repo.ts b/apps/server/src/database/repos/space/space.repo.ts index 149eb1f9..e5bb5472 100644 --- a/apps/server/src/database/repos/space/space.repo.ts +++ b/apps/server/src/database/repos/space/space.repo.ts @@ -128,7 +128,8 @@ export class SpaceRepo { return executeWithCursorPagination(query, { perPage: pagination.limit, - after: pagination.cursor, + cursor: pagination.cursor, + beforeCursor: pagination.beforeCursor, fields: [{ expression: 'id', direction: 'asc' }], parseCursor: (cursor) => ({ id: cursor.id }), }); diff --git a/apps/server/src/database/repos/user/user.repo.ts b/apps/server/src/database/repos/user/user.repo.ts index 2e2f5227..3545e7ec 100644 --- a/apps/server/src/database/repos/user/user.repo.ts +++ b/apps/server/src/database/repos/user/user.repo.ts @@ -163,7 +163,8 @@ export class UserRepo { return executeWithCursorPagination(query, { perPage: pagination.limit, - after: pagination.cursor, + cursor: pagination.cursor, + beforeCursor: pagination.beforeCursor, fields: [{ expression: 'id', direction: 'asc' }], parseCursor: (cursor) => ({ id: cursor.id }), }); diff --git a/apps/server/src/ee b/apps/server/src/ee index fb7257cb..98888322 160000 --- a/apps/server/src/ee +++ b/apps/server/src/ee @@ -1 +1 @@ -Subproject commit fb7257cb4c1917b80d935462a7c4f0ae73ec4fa6 +Subproject commit 9888832270c5f7a7aca4a01a36a072f4d4787e37 diff --git a/apps/server/src/integrations/import/file-task.controller.ts b/apps/server/src/integrations/import/file-task.controller.ts index e937ca72..b604d354 100644 --- a/apps/server/src/integrations/import/file-task.controller.ts +++ b/apps/server/src/integrations/import/file-task.controller.ts @@ -60,7 +60,8 @@ export class FileTaskController { return executeWithCursorPagination(query, { perPage: pagination.limit, - after: pagination.cursor, + cursor: pagination.cursor, + beforeCursor: pagination.beforeCursor, fields: [{ expression: 'id', direction: 'desc' }], parseCursor: (cursor) => ({ id: cursor.id }), });