Skip to content

⚡️⚡️⚡️ Self-hosted collaborative bookmark manager to collect, read, annotate, and fully preserve what matters, all in one place.

refactor: update terminology for subcollection member propagation

daniel31x13f79f57ccda43
diff --git a/apps/web/components/ModalContent/EditCollectionSharingModal.tsx b/apps/web/components/ModalContent/EditCollectionSharingModal.tsx
index c9632a55..36f9e01f 100644
--- a/apps/web/components/ModalContent/EditCollectionSharingModal.tsx
+++ b/apps/web/components/ModalContent/EditCollectionSharingModal.tsx
@@ -61,16 +61,17 @@ export default function EditCollectionSharingModal({
{
onSettled: (data, error) => {
setSubmitLoader(false);
- toast.dismiss(load);
-
- if (error) {
- toast.error(error.message);
- } else {
- onClose();
- toast.success(t("updated"));
- }
- },
- });
+ toast.dismiss(load);
+
+ if (error) {
+ toast.error(error.message);
+ } else {
+ onClose();
+ toast.success(t("updated"));
+ }
+ },
+ }
+ );
}
};
@@ -382,11 +383,11 @@ export default function EditCollectionSharingModal({
className="checkbox checkbox-primary"
/>
<span className="label-text">
- {t("propagate_to_subcollections")}
+ {t("apply_members_roles_to_subcollections")}
</span>
</label>
<p className="text-neutral text-sm">
- {t("propagate_to_subcollections_desc")}
+ {t("apply_members_roles_to_subcollections_desc")}
</p>
</div>
)}
diff --git a/apps/web/lib/api/controllers/collections/collectionId/updateCollectionById.ts b/apps/web/lib/api/controllers/collections/collectionId/updateCollectionById.ts
index b28b898f..933c708f 100644
--- a/apps/web/lib/api/controllers/collections/collectionId/updateCollectionById.ts
+++ b/apps/web/lib/api/controllers/collections/collectionId/updateCollectionById.ts
@@ -69,14 +69,29 @@ export default async function updateCollection(
const getAllSubCollections = async (
parentId: number
): Promise<{ id: number; ownerId: number }[]> => {
- const children = await prisma.collection.findMany({
- where: { parentId },
- select: { id: true, ownerId: true },
- });
- let result = [...children];
- for (const child of children) {
- result = [...result, ...(await getAllSubCollections(child.id))];
+ const result: { id: number; ownerId: number }[] = [];
+
+ let frontier: number[] = [parentId];
+
+ const seen = new Set<number>(frontier);
+
+ while (frontier.length > 0) {
+ const children = await prisma.collection.findMany({
+ where: { parentId: { in: frontier } },
+ select: { id: true, ownerId: true },
+ });
+
+ if (children.length === 0) break;
+
+ for (const child of children) {
+ if (seen.has(child.id)) continue;
+ seen.add(child.id);
+ result.push(child);
+ }
+
+ frontier = children.map((c) => c.id);
}
+
return result;
};
diff --git a/apps/web/public/locales/en/common.json b/apps/web/public/locales/en/common.json
index c5cb4d15..27e59174 100644
--- a/apps/web/public/locales/en/common.json
+++ b/apps/web/public/locales/en/common.json
@@ -526,6 +526,6 @@
"shrink_sidebar": "Shrink Sidebar",
"trial_left_plural": "Trial ends in {{count}} days. Subscribe.",
"trial_left_singular": "Trial ends in 1 day. Subscribe.",
- "propagate_to_subcollections": "Propagate to subcollections",
- "propagate_to_subcollections_desc": "This will update the members of all subcollections to match this collection."
+ "apply_members_roles_to_subcollections": "Apply members and roles to subcollections",
+ "apply_members_roles_to_subcollections_desc": "This will apply the members and their roles to all existing subcollections."
}