🥅 Catch error, if clipboard not enabled (#681)
This commit is contained in:
committed by
Alicia Sykes
parent
972e3f7571
commit
ac97be20be
@@ -2,6 +2,7 @@
|
||||
import axios from 'axios';
|
||||
import router from '@/router';
|
||||
import longPress from '@/directives/LongPress';
|
||||
import ErrorHandler from '@/utils/ErrorHandler';
|
||||
import {
|
||||
openingMethod as defaultOpeningMethod,
|
||||
serviceEndpoints,
|
||||
@@ -149,8 +150,7 @@ export default {
|
||||
router.push({ name: 'workspace', query: { url } });
|
||||
} else if (this.accumulatedTarget === 'clipboard') {
|
||||
e.preventDefault();
|
||||
navigator.clipboard.writeText(url);
|
||||
this.$toasted.show(this.$t('context-menus.item.copied-toast'));
|
||||
this.copyToClipboard(url);
|
||||
}
|
||||
// Emit event to clear search field, etc
|
||||
this.$emit('itemClicked');
|
||||
@@ -178,8 +178,7 @@ export default {
|
||||
router.push({ name: 'workspace', query: { url } });
|
||||
break;
|
||||
case 'clipboard':
|
||||
navigator.clipboard.writeText(url);
|
||||
this.$toasted.show(this.$t('context-menus.item.copied-toast'));
|
||||
this.copyToClipboard(url);
|
||||
break;
|
||||
default: window.open(url, '_blank');
|
||||
}
|
||||
@@ -199,6 +198,19 @@ export default {
|
||||
closeContextMenu() {
|
||||
this.contextMenuOpen = false;
|
||||
},
|
||||
/* Copies a string to the users clipboard / shows error if not possible */
|
||||
copyToClipboard(content) {
|
||||
if (navigator.clipboard) {
|
||||
navigator.clipboard.writeText(content);
|
||||
this.$toasted.show(
|
||||
this.$t('context-menus.item.copied-toast'),
|
||||
{ className: 'toast-success' },
|
||||
);
|
||||
} else {
|
||||
ErrorHandler('Clipboard access requires HTTPS. See: https://bit.ly/3N5WuAA');
|
||||
this.$toasted.show('Unable to copy, see log', { className: 'toast-error' });
|
||||
}
|
||||
},
|
||||
/* Used for smart-sort when sorting items by most used apps */
|
||||
incrementMostUsedCount(itemId) {
|
||||
const mostUsed = JSON.parse(localStorage.getItem(localStorageKeys.MOST_USED) || '{}');
|
||||
|
||||
Reference in New Issue
Block a user