Fix: Add brief timeout before copy after share link creation for Safari, only show if succeeded
This commit is contained in:
parent
9418ca10d5
commit
26901ac280
@ -89,7 +89,7 @@ describe('ShareLinksDropdownComponent', () => {
|
||||
.mockReturnValueOnce(throwError(() => new Error('Unable to get links')))
|
||||
component.documentId = 99
|
||||
|
||||
component.refresh()
|
||||
component.ngOnInit()
|
||||
fixture.detectChanges()
|
||||
expect(toastSpy).toHaveBeenCalled()
|
||||
})
|
||||
@ -104,6 +104,7 @@ describe('ShareLinksDropdownComponent', () => {
|
||||
expiration.setDate(expiration.getDate() + 7)
|
||||
|
||||
const copySpy = jest.spyOn(clipboard, 'copy')
|
||||
copySpy.mockReturnValue(true)
|
||||
const refreshSpy = jest.spyOn(component, 'refresh')
|
||||
|
||||
component.createLink()
|
||||
@ -118,8 +119,10 @@ describe('ShareLinksDropdownComponent', () => {
|
||||
fixture.detectChanges()
|
||||
tick(3000)
|
||||
|
||||
expect(copySpy).toHaveBeenCalled()
|
||||
expect(refreshSpy).toHaveBeenCalled()
|
||||
expect(copySpy).toHaveBeenCalled()
|
||||
expect(component.copied).toEqual(1)
|
||||
tick(100) // copy timeout
|
||||
}))
|
||||
|
||||
it('should show error on link creation if needed', () => {
|
||||
|
@ -98,11 +98,13 @@ export class ShareLinksDropdownComponent implements OnInit {
|
||||
}
|
||||
|
||||
copy(link: PaperlessShareLink) {
|
||||
this.clipboard.copy(this.getShareUrl(link))
|
||||
this.copied = link.id
|
||||
setTimeout(() => {
|
||||
this.copied = null
|
||||
}, 3000)
|
||||
const success = this.clipboard.copy(this.getShareUrl(link))
|
||||
if (success) {
|
||||
this.copied = link.id
|
||||
setTimeout(() => {
|
||||
this.copied = null
|
||||
}, 3000)
|
||||
}
|
||||
}
|
||||
|
||||
canShare(link: PaperlessShareLink): boolean {
|
||||
@ -144,7 +146,9 @@ export class ShareLinksDropdownComponent implements OnInit {
|
||||
.subscribe({
|
||||
next: (result) => {
|
||||
this.loading = false
|
||||
this.copy(result)
|
||||
setTimeout(() => {
|
||||
this.copy(result)
|
||||
}, 10)
|
||||
this.refresh()
|
||||
},
|
||||
error: (e) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user