Refactor Send 'copy link' functionality (#373)
This commit is contained in:
parent
2cf5d767b5
commit
8244971026
|
@ -29,7 +29,7 @@ export abstract class PlatformUtilsService {
|
|||
showPasswordDialog: (title: string, body: string, passwordValidation: (value: string) => Promise<boolean>) => Promise<boolean>;
|
||||
isDev: () => boolean;
|
||||
isSelfHost: () => boolean;
|
||||
copyToClipboard: (text: string, options?: any) => void;
|
||||
copyToClipboard: (text: string, options?: any) => void | boolean;
|
||||
readFromClipboard: (options?: any) => Promise<string>;
|
||||
supportsBiometric: () => Promise<boolean>;
|
||||
authenticateBiometric: () => Promise<boolean>;
|
||||
|
|
|
@ -302,8 +302,6 @@ export class AddEditComponent implements OnInit {
|
|||
this.formPromise = this.encryptSend(file)
|
||||
.then(async encSend => {
|
||||
const uploadPromise = this.sendService.saveWithServer(encSend);
|
||||
let inactive = false;
|
||||
setTimeout(() => inactive = true, 4500);
|
||||
await uploadPromise;
|
||||
if (this.send.id == null) {
|
||||
this.send.id = encSend[0].id;
|
||||
|
@ -312,9 +310,17 @@ export class AddEditComponent implements OnInit {
|
|||
this.send.accessId = encSend[0].accessId;
|
||||
}
|
||||
this.onSavedSend.emit(this.send);
|
||||
await this.showSuccessMessage(inactive);
|
||||
if (this.copyLink) {
|
||||
this.copyLinkToClipboard(this.link);
|
||||
if (this.copyLink && this.link != null) {
|
||||
const copySuccess = await 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;
|
||||
}
|
||||
|
||||
async showSuccessMessage(inactive: boolean) {
|
||||
this.platformUtilsService.showToast('success', null,
|
||||
this.i18nService.t(this.editMode ? 'editedSend' : 'createdSend'));
|
||||
}
|
||||
|
||||
clearExpiration() {
|
||||
this.expirationDate = null;
|
||||
this.expirationDateFallback = null;
|
||||
|
@ -337,10 +338,8 @@ export class AddEditComponent implements OnInit {
|
|||
this.safariExpirationTime = null;
|
||||
}
|
||||
|
||||
copyLinkToClipboard(link: string) {
|
||||
if (link != null) {
|
||||
this.platformUtilsService.copyToClipboard(link);
|
||||
}
|
||||
async copyLinkToClipboard(link: string): Promise<void | boolean> {
|
||||
return Promise.resolve(this.platformUtilsService.copyToClipboard(link));
|
||||
}
|
||||
|
||||
async delete(): Promise<boolean> {
|
||||
|
|
Loading…
Reference in New Issue