Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[web][locker] Allow clearing the default Note collection

AswinAsok98579098e27d
diff --git a/web/apps/locker/src/components/create-item/use-create-item-dialog-state.ts b/web/apps/locker/src/components/create-item/use-create-item-dialog-state.ts
index e3223a13e4..d1ed739281 100644
--- a/web/apps/locker/src/components/create-item/use-create-item-dialog-state.ts
+++ b/web/apps/locker/src/components/create-item/use-create-item-dialog-state.ts
@@ -187,6 +187,7 @@ export const useCreateItemDialogState = ({
const formType =
isEditMode && selectedOption === "file" ? "file" : selectedType;
const displayCollectionsRef = useRef(displayCollections);
+ const defaultCollectionInitializedRef = useRef(false);
displayCollectionsRef.current = displayCollections;
@@ -215,6 +216,8 @@ export const useCreateItemDialogState = ({
(collection) => collection.id === defaultCollectionID,
)?.name
: undefined;
+ defaultCollectionInitializedRef.current =
+ defaultCollectionName !== undefined;
setSelectedCollectionIDs(
isEditMode
? normalizeSelectedCollectionIDs(
@@ -286,6 +289,7 @@ export const useCreateItemDialogState = ({
if (
!open ||
isEditMode ||
+ defaultCollectionInitializedRef.current ||
selectedCollectionIDs.length > 0 ||
defaultCollectionID === null ||
defaultCollectionID === undefined ||
@@ -296,6 +300,7 @@ export const useCreateItemDialogState = ({
return;
}
+ defaultCollectionInitializedRef.current = true;
setSelectedCollectionIDs([defaultCollectionID]);
}, [
defaultCollectionID,