Skip to content

armgit / ente

Public Imported from GitHub
0

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

Save to uncategorized by default

Vishnu Mohandase4308648c791
diff --git a/web/apps/locker/src/components/createItemDialog/useCreateItemDialogState.ts b/web/apps/locker/src/components/createItemDialog/useCreateItemDialogState.ts
index 7b71a06c41..2423dc2f0f 100644
--- a/web/apps/locker/src/components/createItemDialog/useCreateItemDialogState.ts
+++ b/web/apps/locker/src/components/createItemDialog/useCreateItemDialogState.ts
@@ -14,7 +14,11 @@ import type {
LockerItemType,
LockerUploadCandidate,
} from "types";
-import { isCollectionOwner, visibleLockerCollections } from "types";
+import {
+ isCollectionOwner,
+ isUncategorizedCollection,
+ visibleLockerCollections,
+} from "types";
import {
collectionNamesByUploadItem,
dedupeCollectionNames,
@@ -127,7 +131,9 @@ export const useCreateItemDialogState = ({
);
if (!isEditMode) {
- return ownedVisibleCollections;
+ return ownedVisibleCollections.filter(
+ (collection) => !isUncategorizedCollection(collection),
+ );
}
const visibleCollectionIDSet = new Set(
@@ -400,7 +406,7 @@ export const useCreateItemDialogState = ({
);
const handleSave = useCallback(async () => {
- if (!formType || (!isEditMode && selectedCollectionIDs.length === 0)) {
+ if (!formType) {
return;
}
@@ -433,14 +439,7 @@ export const useCreateItemDialogState = ({
} finally {
setSaving(false);
}
- }, [
- formData,
- formType,
- handleClose,
- isEditMode,
- onSave,
- selectedCollectionIDs,
- ]);
+ }, [formData, formType, handleClose, onSave, selectedCollectionIDs]);
const handleUpload = useCallback(async () => {
if (selectedUploadItems.length === 0 || !onUploadProgress) {
@@ -521,16 +520,6 @@ export const useCreateItemDialogState = ({
return { item, fileKey, collectionIDs };
});
- if (
- uploadTargets.some(
- ({ collectionIDs }) => collectionIDs.length === 0,
- )
- ) {
- setError(t("required_field"));
- setUpgradeCTAType(null);
- return;
- }
-
let nextIndex = 0;
const worker = async () => {
while (true) {
@@ -640,7 +629,6 @@ export const useCreateItemDialogState = ({
const canSave =
formType !== null &&
- (isEditMode || selectedCollectionIDs.length > 0) &&
getRequiredFields(formType).every(
(field) =>
typeof formData[field] === "string" && formData[field].trim(),
@@ -648,11 +636,6 @@ export const useCreateItemDialogState = ({
const canUpload =
isFileMode &&
selectedUploadItems.length > 0 &&
- selectedUploadItems.every(
- (item) =>
- (selectedCollectionNamesByFileKey[uploadQueueItemKey(item)]
- ?.length ?? 0) > 0,
- ) &&
selectedUploadItems.some(
(item) => !completedFileKeys.has(uploadQueueItemKey(item)),
);
diff --git a/web/apps/locker/src/services/remote.ts b/web/apps/locker/src/services/remote.ts
index 5264a40284..8b3d85324f 100644
--- a/web/apps/locker/src/services/remote.ts
+++ b/web/apps/locker/src/services/remote.ts
@@ -202,6 +202,14 @@ const infoItemTitle = (
}
};
+const resolveCollectionIDsWithUncategorizedFallback = async (
+ collectionIDs: number[],
+ masterKey: string,
+) =>
+ collectionIDs.length > 0
+ ? Array.from(new Set(collectionIDs))
+ : [(await ensureUncategorizedCollection(masterKey)).id];
+
/**
* Fetch Locker file share links for the current user.
*
@@ -290,12 +298,13 @@ export const deleteLockerFileShareLink = async (
// ---------------------------------------------------------------------------
/**
- * Create a new info item in the specified collection.
+ * Create a new info item in the specified collection(s).
*
* This uses the `/files/meta` endpoint for metadata-only files (no file
* content blob, no thumbnail). The info data is stored in pubMagicMetadata.
*
- * @param collectionID The collection to create the item in.
+ * @param collectionIDs The collection IDs to create the item in. Falls back
+ * to the user's Uncategorized collection when empty.
* @param infoType The item type (e.g. "note", "accountCredential").
* @param infoData The item's structured data (matching the type's schema).
* @param masterKey The user's master key.
@@ -306,7 +315,11 @@ export const createInfoItem = async (
infoData: Record<string, unknown>,
masterKey: string,
): Promise<void> => {
- const [collectionID, ...additionalCollectionIDs] = collectionIDs;
+ const [collectionID, ...additionalCollectionIDs] =
+ await resolveCollectionIDsWithUncategorizedFallback(
+ collectionIDs,
+ masterKey,
+ );
if (collectionID === undefined) {
throw new Error("No collection selected");
}
@@ -1084,9 +1097,14 @@ export const uploadLockerFile = async (
masterKey: string,
onProgress?: (progress: LockerUploadProgress) => void,
): Promise<number> => {
+ const targetCollectionIDs =
+ await resolveCollectionIDsWithUncategorizedFallback(
+ collectionIDs,
+ masterKey,
+ );
return uploadLockerFileWithDeps(
file,
- collectionIDs,
+ targetCollectionIDs,
masterKey,
{ getCollectionRecord, decryptCollectionKey, addFileToCollections },
onProgress,