From fd5dfdb47e18c94a40490c246998213af2c321f8 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sat, 1 Aug 2026 18:47:49 -0400 Subject: [PATCH] fix: Empty collaborators displayed on fresh model (#13231) --- app/components/Collaborators.tsx | 2 +- app/models/Document.ts | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/components/Collaborators.tsx b/app/components/Collaborators.tsx index 7e0ab25bfa..531cb8f1e2 100644 --- a/app/components/Collaborators.tsx +++ b/app/components/Collaborators.tsx @@ -61,7 +61,7 @@ function Collaborators(props: Props) { // ensure currently present via websocket are always ordered first // Memoize collaboratorIds as a Set for efficient lookup const collaboratorIdsSet = useMemo( - () => new Set(document.collaboratorIds), + () => new Set(document.collaboratorIds ?? []), [document.collaboratorIds] ); const collaborators = useMemo( diff --git a/app/models/Document.ts b/app/models/Document.ts index 955d753bae..2e7276372a 100644 --- a/app/models/Document.ts +++ b/app/models/Document.ts @@ -181,8 +181,11 @@ export default class Document extends ArchivableModel implements Searchable { @Relation(() => Document, { onArchive: "cascade", onDelete: "cascade" }) parentDocument?: Document; + /** + * The ids of users that have edited this document. + */ @observable - collaboratorIds: string[] = []; + collaboratorIds: string[] | undefined; @Relation(() => User) createdBy: User | undefined; @@ -309,7 +312,7 @@ export default class Document extends ArchivableModel implements Searchable { @computed get collaborators(): User[] { - return this.collaboratorIds + return (this.collaboratorIds ?? []) .map((id) => this.store.rootStore.users.get(id)) .filter(Boolean) as User[]; }