mirror of
https://github.com/outline/outline.git
synced 2026-11-29 00:29:36 +03:00
Simplify membershipType logic
This commit is contained in:
1 parent
d1931de805
commit
e2a0f1bc44
2 files changed
+6
-20
No files matched your search
@@ -40,18 +40,18 @@ export const determineSidebarContext = ({
|
||||
: starredSidebarContext(document.collectionId!);
|
||||
}
|
||||
|
||||
const membershipType = document.membershipType;
|
||||
|
||||
if (membershipType === "document") {
|
||||
if (document.collection) {
|
||||
return "collections";
|
||||
} else if (
|
||||
user.documentMemberships.find((m) => m.documentId === document.id)
|
||||
) {
|
||||
return "shared";
|
||||
} else if (membershipType === "group") {
|
||||
} else {
|
||||
const group = user.groupsWithDocumentMemberships.find(
|
||||
(g) => !!g.documentMemberships.find((m) => m.documentId === document.id)
|
||||
);
|
||||
return groupSidebarContext(group?.id ?? "");
|
||||
}
|
||||
|
||||
return "collections";
|
||||
};
|
||||
|
||||
export default SidebarContext;
|
||||
@@ -426,20 +426,6 @@ export default class Document extends ArchivableModel {
|
||||
return this.title || i18n.t("Untitled");
|
||||
}
|
||||
|
||||
@computed
|
||||
get membershipType(): "collection" | "document" | "group" {
|
||||
if (this.collection) {
|
||||
return "collection";
|
||||
}
|
||||
|
||||
const hasDocumentMembership =
|
||||
this.store.rootStore.auth.user?.documentMemberships.find(
|
||||
(m) => m.documentId === this.id
|
||||
) ?? false;
|
||||
|
||||
return hasDocumentMembership ? "document" : "group";
|
||||
}
|
||||
|
||||
@action
|
||||
updateTasks(total: number, completed: number) {
|
||||
if (total !== this.tasks.total || completed !== this.tasks.completed) {
|
||||
|
||||
Reference in new issue
Block a user