mirror of
https://github.com/bitwarden/browser
synced 2025-12-20 02:03:39 +00:00
Refactor Send 'copy link' functionality (#373)
This commit is contained in:
@@ -29,7 +29,7 @@ export abstract class PlatformUtilsService {
|
|||||||
showPasswordDialog: (title: string, body: string, passwordValidation: (value: string) => Promise<boolean>) => Promise<boolean>;
|
showPasswordDialog: (title: string, body: string, passwordValidation: (value: string) => Promise<boolean>) => Promise<boolean>;
|
||||||
isDev: () => boolean;
|
isDev: () => boolean;
|
||||||
isSelfHost: () => boolean;
|
isSelfHost: () => boolean;
|
||||||
copyToClipboard: (text: string, options?: any) => void;
|
copyToClipboard: (text: string, options?: any) => void | boolean;
|
||||||
readFromClipboard: (options?: any) => Promise<string>;
|
readFromClipboard: (options?: any) => Promise<string>;
|
||||||
supportsBiometric: () => Promise<boolean>;
|
supportsBiometric: () => Promise<boolean>;
|
||||||
authenticateBiometric: () => Promise<boolean>;
|
authenticateBiometric: () => Promise<boolean>;
|
||||||
|
|||||||
@@ -302,8 +302,6 @@ export class AddEditComponent implements OnInit {
|
|||||||
this.formPromise = this.encryptSend(file)
|
this.formPromise = this.encryptSend(file)
|
||||||
.then(async encSend => {
|
.then(async encSend => {
|
||||||
const uploadPromise = this.sendService.saveWithServer(encSend);
|
const uploadPromise = this.sendService.saveWithServer(encSend);
|
||||||
let inactive = false;
|
|
||||||
setTimeout(() => inactive = true, 4500);
|
|
||||||
await uploadPromise;
|
await uploadPromise;
|
||||||
if (this.send.id == null) {
|
if (this.send.id == null) {
|
||||||
this.send.id = encSend[0].id;
|
this.send.id = encSend[0].id;
|
||||||
@@ -312,9 +310,17 @@ export class AddEditComponent implements OnInit {
|
|||||||
this.send.accessId = encSend[0].accessId;
|
this.send.accessId = encSend[0].accessId;
|
||||||
}
|
}
|
||||||
this.onSavedSend.emit(this.send);
|
this.onSavedSend.emit(this.send);
|
||||||
await this.showSuccessMessage(inactive);
|
if (this.copyLink && this.link != null) {
|
||||||
if (this.copyLink) {
|
const copySuccess = await this.copyLinkToClipboard(this.link);
|
||||||
this.copyLinkToClipboard(this.link);
|
if (copySuccess ?? true) {
|
||||||
|
this.platformUtilsService.showToast('success', null,
|
||||||
|
this.i18nService.t(this.editMode ? 'editedSend' : 'createdSend'));
|
||||||
|
} else {
|
||||||
|
await this.platformUtilsService.showDialog(
|
||||||
|
this.i18nService.t(this.editMode ? 'editedSend' : 'createdSend'), null,
|
||||||
|
this.i18nService.t('ok'), null, 'success', null);
|
||||||
|
await this.copyLinkToClipboard(this.link);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -325,11 +331,6 @@ export class AddEditComponent implements OnInit {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
async showSuccessMessage(inactive: boolean) {
|
|
||||||
this.platformUtilsService.showToast('success', null,
|
|
||||||
this.i18nService.t(this.editMode ? 'editedSend' : 'createdSend'));
|
|
||||||
}
|
|
||||||
|
|
||||||
clearExpiration() {
|
clearExpiration() {
|
||||||
this.expirationDate = null;
|
this.expirationDate = null;
|
||||||
this.expirationDateFallback = null;
|
this.expirationDateFallback = null;
|
||||||
@@ -337,10 +338,8 @@ export class AddEditComponent implements OnInit {
|
|||||||
this.safariExpirationTime = null;
|
this.safariExpirationTime = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
copyLinkToClipboard(link: string) {
|
async copyLinkToClipboard(link: string): Promise<void | boolean> {
|
||||||
if (link != null) {
|
return Promise.resolve(this.platformUtilsService.copyToClipboard(link));
|
||||||
this.platformUtilsService.copyToClipboard(link);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async delete(): Promise<boolean> {
|
async delete(): Promise<boolean> {
|
||||||
|
|||||||
Reference in New Issue
Block a user