diff --git a/src/qortalRequests/get.ts b/src/qortalRequests/get.ts index 6e2c09d..0020a09 100644 --- a/src/qortalRequests/get.ts +++ b/src/qortalRequests/get.ts @@ -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); diff --git a/src/utils/time.ts b/src/utils/time.ts index e434cfb..d8d1ef4 100644 --- a/src/utils/time.ts +++ b/src/utils/time.ts @@ -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); } }); }