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')))
|
.mockReturnValueOnce(throwError(() => new Error('Unable to get links')))
|
||||||
component.documentId = 99
|
component.documentId = 99
|
||||||
|
|
||||||
component.refresh()
|
component.ngOnInit()
|
||||||
fixture.detectChanges()
|
fixture.detectChanges()
|
||||||
expect(toastSpy).toHaveBeenCalled()
|
expect(toastSpy).toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
@ -104,6 +104,7 @@ describe('ShareLinksDropdownComponent', () => {
|
|||||||
expiration.setDate(expiration.getDate() + 7)
|
expiration.setDate(expiration.getDate() + 7)
|
||||||
|
|
||||||
const copySpy = jest.spyOn(clipboard, 'copy')
|
const copySpy = jest.spyOn(clipboard, 'copy')
|
||||||
|
copySpy.mockReturnValue(true)
|
||||||
const refreshSpy = jest.spyOn(component, 'refresh')
|
const refreshSpy = jest.spyOn(component, 'refresh')
|
||||||
|
|
||||||
component.createLink()
|
component.createLink()
|
||||||
@ -118,8 +119,10 @@ describe('ShareLinksDropdownComponent', () => {
|
|||||||
fixture.detectChanges()
|
fixture.detectChanges()
|
||||||
tick(3000)
|
tick(3000)
|
||||||
|
|
||||||
expect(copySpy).toHaveBeenCalled()
|
|
||||||
expect(refreshSpy).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', () => {
|
it('should show error on link creation if needed', () => {
|
||||||
|
@ -98,12 +98,14 @@ export class ShareLinksDropdownComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
copy(link: PaperlessShareLink) {
|
copy(link: PaperlessShareLink) {
|
||||||
this.clipboard.copy(this.getShareUrl(link))
|
const success = this.clipboard.copy(this.getShareUrl(link))
|
||||||
|
if (success) {
|
||||||
this.copied = link.id
|
this.copied = link.id
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.copied = null
|
this.copied = null
|
||||||
}, 3000)
|
}, 3000)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
canShare(link: PaperlessShareLink): boolean {
|
canShare(link: PaperlessShareLink): boolean {
|
||||||
return (
|
return (
|
||||||
@ -144,7 +146,9 @@ export class ShareLinksDropdownComponent implements OnInit {
|
|||||||
.subscribe({
|
.subscribe({
|
||||||
next: (result) => {
|
next: (result) => {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
|
setTimeout(() => {
|
||||||
this.copy(result)
|
this.copy(result)
|
||||||
|
}, 10)
|
||||||
this.refresh()
|
this.refresh()
|
||||||
},
|
},
|
||||||
error: (e) => {
|
error: (e) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user