diff --git a/jslib b/jslib index a72c8a60..82449710 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit a72c8a60c1b7a6980bceee456c53a9ea7b9b3451 +Subproject commit 8244971026ffefb962e235a79c5cb219163bead9 diff --git a/src/app/send/add-edit.component.ts b/src/app/send/add-edit.component.ts index 9a13d77e..0d577dce 100644 --- a/src/app/send/add-edit.component.ts +++ b/src/app/send/add-edit.component.ts @@ -12,8 +12,6 @@ import { UserService } from 'jslib/abstractions/user.service'; import { AddEditComponent as BaseAddEditComponent } from 'jslib/angular/components/send/add-edit.component'; -import { SendType } from 'jslib/enums/sendType'; - @Component({ selector: 'app-send-add-edit', templateUrl: 'add-edit.component.html', @@ -27,18 +25,11 @@ export class AddEditComponent extends BaseAddEditComponent { messagingService, policyService); } - async showSuccessMessage(inactive: boolean) { - if (inactive && this.copyLink && this.send.type === SendType.File) { - await this.platformUtilsService.showDialog(this.i18nService.t('createdSend'), null, - this.i18nService.t('ok'), null, 'success', null); - } else { - await super.showSuccessMessage(inactive); - } - } - - copyLinkToClipboard(link: string) { + async copyLinkToClipboard(link: string): Promise { // Copy function on web depends on the modal being open or not. Since this event occurs during a transition // of the modal closing we need to add a small delay to make sure state of the DOM is consistent. - window.setTimeout(() => super.copyLinkToClipboard(link), 500); + return new Promise(resolve => { + window.setTimeout(() => resolve(super.copyLinkToClipboard(link)), 500); + }); } } diff --git a/src/app/services/services.module.ts b/src/app/services/services.module.ts index ce0c07c4..2b59c700 100644 --- a/src/app/services/services.module.ts +++ b/src/app/services/services.module.ts @@ -91,12 +91,12 @@ const i18nService = new I18nService(window.navigator.language, 'locales'); const stateService = new StateService(); const broadcasterService = new BroadcasterService(); const messagingService = new BroadcasterMessagingService(broadcasterService); -const platformUtilsService = new WebPlatformUtilsService(i18nService, messagingService); +const consoleLogService = new ConsoleLogService(false); +const platformUtilsService = new WebPlatformUtilsService(i18nService, messagingService, consoleLogService); const storageService: StorageServiceAbstraction = new HtmlStorageService(platformUtilsService); const secureStorageService: StorageServiceAbstraction = new MemoryStorageService(); const cryptoFunctionService: CryptoFunctionServiceAbstraction = new WebCryptoFunctionService(window, platformUtilsService); -const consoleLogService = new ConsoleLogService(false); const cryptoService = new CryptoService(storageService, platformUtilsService.isDev() ? storageService : secureStorageService, cryptoFunctionService, platformUtilsService, consoleLogService); diff --git a/src/services/webPlatformUtils.service.ts b/src/services/webPlatformUtils.service.ts index 286298f1..dc942261 100644 --- a/src/services/webPlatformUtils.service.ts +++ b/src/services/webPlatformUtils.service.ts @@ -3,6 +3,7 @@ import Swal, { SweetAlertIcon } from 'sweetalert2'; import { DeviceType } from 'jslib/enums/deviceType'; import { I18nService } from 'jslib/abstractions/i18n.service'; +import { LogService } from 'jslib/abstractions/log.service'; import { MessagingService } from 'jslib/abstractions/messaging.service'; import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; @@ -11,7 +12,8 @@ export class WebPlatformUtilsService implements PlatformUtilsService { private browserCache: DeviceType = null; - constructor(private i18nService: I18nService, private messagingService: MessagingService) { } + constructor(private i18nService: I18nService, private messagingService: MessagingService, + private logService: LogService) { } getDevice(): DeviceType { if (this.browserCache != null) { @@ -245,7 +247,7 @@ export class WebPlatformUtilsService implements PlatformUtilsService { return process.env.SELF_HOST.toString() === 'true'; } - copyToClipboard(text: string, options?: any): void { + copyToClipboard(text: string, options?: any): void | boolean { let win = window; let doc = window.document; if (options && (options.window || options.win)) { @@ -269,11 +271,12 @@ export class WebPlatformUtilsService implements PlatformUtilsService { } copyEl.appendChild(textarea); textarea.select(); + let success = false; try { // Security exception may be thrown by some browsers. - const copyEnabled = doc.execCommand('copy'); - if (!copyEnabled) { - throw new Error('Command unsupported or disabled'); + success = doc.execCommand('copy'); + if (!success) { + this.logService.debug('Copy command unsupported or disabled.'); } } catch (e) { // tslint:disable-next-line @@ -281,6 +284,7 @@ export class WebPlatformUtilsService implements PlatformUtilsService { } finally { copyEl.removeChild(textarea); } + return success; } }