Skip to content

Commit

Permalink
node-share: await clipboard writes
Browse files Browse the repository at this point in the history
Signed-off-by: Varun Patil <radialapps@gmail.com>
  • Loading branch information
pulsejet committed Nov 13, 2023
1 parent fa644b1 commit 2945854
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/components/modal/NodeShareModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
import { defineComponent } from 'vue';
import axios from '@nextcloud/axios';
import { showSuccess } from '@nextcloud/dialogs';
import { showError, showSuccess } from '@nextcloud/dialogs';
import NcButton from '@nextcloud/vue/dist/Components/NcButton';
const NcListItem = () => import('@nextcloud/vue/dist/Components/NcListItem');
Expand Down Expand Up @@ -152,12 +152,12 @@ export default defineComponent({
}
},
shareOrCopy(url: string) {
async shareOrCopy(url: string) {
if (nativex.has()) {
nativex.shareUrl(url);
} else if ('share' in window.navigator) {
await this.copy(url);
window.navigator.share({ title: this.filename, url: url });
this.copy(url);
}
},
Expand Down Expand Up @@ -226,9 +226,13 @@ export default defineComponent({
this.refreshSidebar();
},
copy(url: string) {
window.navigator.clipboard.writeText(url);
showSuccess(this.t('memories', 'Link copied to clipboard'));
async copy(url: string) {
try {
await window.navigator.clipboard.writeText(url);
showSuccess(this.t('memories', 'Link copied to clipboard'));
} catch (e) {
showError(this.t('memories', 'Failed to copy link to clipboard'));
}
},
refreshSidebar() {
Expand Down

0 comments on commit 2945854

Please sign in to comment.