mirror of
https://github.com/vector-im/element-web.git
synced 2024-09-10 07:05:14 +00:00
Abstract electron download path behind an opaque ID (#20271)
This commit is contained in:
parent
30cb0ae96d
commit
211f480027
2 changed files with 9 additions and 4 deletions
2
src/@types/global.d.ts
vendored
2
src/@types/global.d.ts
vendored
|
@ -32,7 +32,7 @@ type ElectronChannel =
|
||||||
"setBadgeCount" |
|
"setBadgeCount" |
|
||||||
"update-downloaded" |
|
"update-downloaded" |
|
||||||
"userDownloadCompleted" |
|
"userDownloadCompleted" |
|
||||||
"userDownloadOpen";
|
"userDownloadAction";
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface Window {
|
interface Window {
|
||||||
|
|
|
@ -258,14 +258,18 @@ export default class ElectronPlatform extends VectorBasePlatform {
|
||||||
dis.fire(Action.ViewUserSettings);
|
dis.fire(Action.ViewUserSettings);
|
||||||
});
|
});
|
||||||
|
|
||||||
electron.on('userDownloadCompleted', (ev, { path, name }) => {
|
electron.on('userDownloadCompleted', (ev, { id, name }) => {
|
||||||
const key = `DOWNLOAD_TOAST_${path}`;
|
const key = `DOWNLOAD_TOAST_${id}`;
|
||||||
|
|
||||||
const onAccept = () => {
|
const onAccept = () => {
|
||||||
electron.send('userDownloadOpen', { path });
|
electron.send('userDownloadAction', { id, open: true });
|
||||||
ToastStore.sharedInstance().dismissToast(key);
|
ToastStore.sharedInstance().dismissToast(key);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onDismiss = () => {
|
||||||
|
electron.send('userDownloadAction', { id });
|
||||||
|
};
|
||||||
|
|
||||||
ToastStore.sharedInstance().addOrReplaceToast({
|
ToastStore.sharedInstance().addOrReplaceToast({
|
||||||
key,
|
key,
|
||||||
title: _t("Download Completed"),
|
title: _t("Download Completed"),
|
||||||
|
@ -274,6 +278,7 @@ export default class ElectronPlatform extends VectorBasePlatform {
|
||||||
acceptLabel: _t("Open"),
|
acceptLabel: _t("Open"),
|
||||||
onAccept,
|
onAccept,
|
||||||
dismissLabel: _t("Dismiss"),
|
dismissLabel: _t("Dismiss"),
|
||||||
|
onDismiss,
|
||||||
numSeconds: 10,
|
numSeconds: 10,
|
||||||
},
|
},
|
||||||
component: GenericExpiringToast,
|
component: GenericExpiringToast,
|
||||||
|
|
Loading…
Reference in a new issue