save_file update

This commit is contained in:
PhilReact 2025-05-22 01:32:34 +03:00
parent ac508112d1
commit 69c9959a87
2 changed files with 8 additions and 5 deletions

View File

@ -1949,7 +1949,10 @@ export const saveFile = async (data, sender, isFromExtension, snackMethods) => {
if (data.location.identifier) {
locationUrl = locationUrl + `/${data.location.identifier}`;
}
const endpoint = await createEndpoint(locationUrl);
const endpoint = await createEndpoint(
locationUrl +
`?attachment=true&attachmentFilename=${data?.location?.filename}`
);
a.href = endpoint;
a.download = data.location.filename;
document.body.appendChild(a);

View File

@ -44,14 +44,14 @@ export function sortArrayByTimestampAndGroupName(array) {
// Both have timestamp, sort by timestamp descending
return b.timestamp - a.timestamp;
} else if (a.timestamp) {
// Only `a` has timestamp, it comes first
return -1;
} else if (b.timestamp) {
// Only `b` has timestamp, it comes first
return 1;
} else {
// Neither has timestamp, sort alphabetically by groupName
return a.groupName.localeCompare(b.groupName);
// Neither has timestamp, sort alphabetically by groupName (with fallback)
const nameA = a.groupName || '';
const nameB = b.groupName || '';
return nameA.localeCompare(nameB);
}
});
}