diff --git a/electron-projects/ucap-webmessenger-electron/src/index.ts b/electron-projects/ucap-webmessenger-electron/src/index.ts index dcfc113a..313a4149 100644 --- a/electron-projects/ucap-webmessenger-electron/src/index.ts +++ b/electron-projects/ucap-webmessenger-electron/src/index.ts @@ -603,7 +603,10 @@ ipcMain.on( dialog .showSaveDialog({ defaultPath: args[0] }) .then(obj => { - event.returnValue = obj.filePath; + event.returnValue = { + canceled: obj.canceled, + filePath: obj.filePath + }; }) .catch(obj => { event.returnValue = undefined; diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts index adea76cd..f6e766fb 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts @@ -918,15 +918,19 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit { this.nativeService .selectSaveFilePath(value.fileInfo.fileName) .then(result => { - if (!!result && result.length > 0) { - this.saveFile(value, result); + if (!!result && result.filePath.length > 0) { + this.saveFile(value, result.filePath); } else { - this.snackBarService.open( - this.translateService.instant( - 'common.file.errors.failToSpecifyPath' - ), - this.translateService.instant('common.file.errors.label') - ); + if (!!result && result.canceled) { + // ignore.. + } else { + this.snackBarService.open( + this.translateService.instant( + 'common.file.errors.failToSpecifyPath' + ), + this.translateService.instant('common.file.errors.label') + ); + } } }) .catch(reason => { diff --git a/projects/ucap-webmessenger-native-browser/src/lib/services/browser-native.service.ts b/projects/ucap-webmessenger-native-browser/src/lib/services/browser-native.service.ts index 4bbbc99f..7460f818 100644 --- a/projects/ucap-webmessenger-native-browser/src/lib/services/browser-native.service.ts +++ b/projects/ucap-webmessenger-native-browser/src/lib/services/browser-native.service.ts @@ -187,9 +187,18 @@ export class BrowserNativeService extends NativeService { }); } - selectSaveFilePath(defaultPath?: string): Promise { - return new Promise((resolve, reject) => { - resolve(''); + selectSaveFilePath(defaultPath?: string): Promise<{ + canceled: boolean, + filePath: string + }> { + return new Promise<{ + canceled: boolean, + filePath: string + }>((resolve, reject) => { + resolve({ + canceled: false, + filePath: '' + }); }); } diff --git a/projects/ucap-webmessenger-native-electron/src/lib/services/electron-native.service.ts b/projects/ucap-webmessenger-native-electron/src/lib/services/electron-native.service.ts index c54ae3ab..2b37b986 100644 --- a/projects/ucap-webmessenger-native-electron/src/lib/services/electron-native.service.ts +++ b/projects/ucap-webmessenger-native-electron/src/lib/services/electron-native.service.ts @@ -309,8 +309,14 @@ export class ElectronNativeService implements NativeService { }); } - selectSaveFilePath(defaultPath?: string): Promise { - return new Promise((resolve, reject) => { + selectSaveFilePath(defaultPath?: string): Promise<{ + canceled: boolean, + filePath: string + }> { + return new Promise<{ + canceled: boolean, + filePath: string + }>((resolve, reject) => { try { resolve( this.ipcRenderer.sendSync(FileChannel.SelectSaveFilePath, defaultPath) diff --git a/projects/ucap-webmessenger-native/src/lib/services/native.service.ts b/projects/ucap-webmessenger-native/src/lib/services/native.service.ts index 43cc5328..e456dcb0 100644 --- a/projects/ucap-webmessenger-native/src/lib/services/native.service.ts +++ b/projects/ucap-webmessenger-native/src/lib/services/native.service.ts @@ -59,7 +59,10 @@ export abstract class NativeService { abstract openTargetItem(filePath?: string): Promise; abstract getPath(name: NativePathName): Promise; abstract selectDirectory(): Promise; - abstract selectSaveFilePath(defaultPath?: string): Promise; + abstract selectSaveFilePath(defaultPath?: string): Promise<{ + canceled: boolean, + filePath: string + }>; abstract executeProcess(executableName: string): Promise;