Files
bookorbit/client/src/features/collection/lib/collection-access.ts
T
neon 5a668b0015 feat(collections): add public collections with shared read access
Add an isPublic flag to collections allowing users to share collections across the instance. Public collections are readable by all authenticated users while write, edit, reorder, and delete operations remain restricted to the owner.
2026-08-28 16:13:28 +00:00

14 lines
523 B
TypeScript

import type { Collection } from '@bookorbit/types'
export function canMutateCollection(collection: Collection | null | undefined): boolean {
return collection?.isOwner === true
}
export function ownedCollectionOrder(
collections: readonly Collection[],
order: readonly { id: number; displayOrder: number }[],
): { id: number; displayOrder: number }[] {
const ownedIds = new Set(collections.filter(canMutateCollection).map((collection) => collection.id))
return order.filter((entry) => ownedIds.has(entry.id))
}