1
0
mirror of https://github.com/bitwarden/web synced 2025-12-16 16:23:31 +00:00

Refactor Send 'copy link' functionality (#960)

* Refactor Send 'copy link' functionality

* bump jslib

* Print debug message if copyToClipboard fails

* fix linting
This commit is contained in:
Thomas Rittson
2021-05-12 10:51:12 +10:00
committed by GitHub
parent 97e1c7a2ea
commit 3ac2ce079a
4 changed files with 16 additions and 21 deletions

View File

@@ -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<void | boolean> {
// 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);
});
}
}