Fix button label for save dialog

This commit is contained in:
Fedor Indutny
2025-06-04 09:14:07 -07:00
committed by GitHub
parent c2ff41b520
commit 30bc3c14a8
3 changed files with 30 additions and 5 deletions

View File

@@ -8414,6 +8414,10 @@
"messageformat": "Don't share personal information with people you don't know",
"description": "Third list item in profile name warning modal for group conversations"
},
"icu:SaveMultiDialog__title": {
"messageformat": "Save attachments",
"description": "Title of the dialog to save multiple attachments"
},
"icu:WhatsNew__modal-title": {
"messageformat": "What's New",
"description": "Title for the whats new modal"

View File

@@ -3122,7 +3122,15 @@ ipc.handle(
'show-open-folder-dialog',
async (
_event,
{ useMainWindow }: { useMainWindow: boolean } = { useMainWindow: false }
{
useMainWindow,
buttonLabel,
title,
}: {
useMainWindow: boolean;
buttonLabel?: string;
title?: string;
} = { useMainWindow: false }
) => {
let canceled: boolean;
let selectedDirPaths: ReadonlyArray<string>;
@@ -3138,12 +3146,16 @@ ipc.handle(
{
defaultPath: app.getPath('downloads'),
properties: ['openDirectory', 'createDirectory'],
buttonLabel,
title,
}
));
} else {
({ canceled, filePaths: selectedDirPaths } = await dialog.showOpenDialog({
defaultPath: app.getPath('downloads'),
properties: ['openDirectory', 'createDirectory'],
buttonLabel,
title,
}));
}

View File

@@ -29,6 +29,7 @@ import { drop } from '../../util/drop';
import type { DurationInSeconds } from '../../util/durations';
import * as universalExpireTimer from '../../util/universalExpireTimer';
import * as Attachment from '../../types/Attachment';
import type { LocalizerType } from '../../types/I18N';
import { AttachmentDownloadUrgency } from '../../types/AttachmentDownload';
import { isFileDangerous } from '../../util/isFileDangerous';
import { getLocalAttachmentUrl } from '../../util/getLocalAttachmentUrl';
@@ -4121,11 +4122,17 @@ function saveAttachment(
};
}
const showSaveMultiDialog = (): Promise<{
const showSaveMultiDialog = (
i18n: LocalizerType
): Promise<{
canceled: boolean;
dirPath?: string;
}> => {
return ipcRenderer.invoke('show-open-folder-dialog', { useMainWindow: true });
return ipcRenderer.invoke('show-open-folder-dialog', {
useMainWindow: true,
title: i18n('icu:SaveMultiDialog__title'),
buttonLabel: i18n('icu:save'),
});
};
export type SaveAttachmentsActionCreatorType = ReadonlyDeep<
@@ -4140,7 +4147,7 @@ function saveAttachments(
attachments: ReadonlyArray<AttachmentType>,
timestamp = Date.now()
): ThunkAction<void, RootStateType, unknown, ShowToastActionType> {
return async dispatch => {
return async (dispatch, getState) => {
// check if any of the attachments could be dangerous
for (const attachment of attachments) {
const { fileName = '' } = attachment;
@@ -4157,7 +4164,9 @@ function saveAttachments(
}
}
const { canceled, dirPath } = await showSaveMultiDialog();
const { canceled, dirPath } = await showSaveMultiDialog(
getIntl(getState())
);
if (canceled || !dirPath) {
return;
}