From 69c9959a8752624753c037594fdf03a42bde8c70 Mon Sep 17 00:00:00 2001 From: PhilReact Date: Thu, 22 May 2025 01:32:34 +0300 Subject: [PATCH] save_file update --- src/qortalRequests/get.ts | 5 ++++- src/utils/time.ts | 8 ++++---- 2 files changed, 8 insertions(+), 5 deletions(-) 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); } }); }