diff --git a/src/components/Dashboard/TRC/RightClickMenu.vue b/src/components/Dashboard/TRC/RightClickMenu.vue index 74aa8dc0..5b1d8c71 100644 --- a/src/components/Dashboard/TRC/RightClickMenu.vue +++ b/src/components/Dashboard/TRC/RightClickMenu.vue @@ -10,6 +10,7 @@ import { TRCMenuEntry } from '@/types/vuetorrent' import { computed } from 'vue' import { useI18n } from 'vue-i18n' import { useRouter } from 'vue-router' +import { toast } from 'vue3-toastify' const props = defineProps<{ modelValue: boolean @@ -94,7 +95,14 @@ async function toggleTag(tag: string) { } async function copyValue(valueToCopy: string) { - await navigator.clipboard.writeText(valueToCopy) + try { + await navigator.clipboard.writeText(valueToCopy) + } catch (error) { + toast.error(t('toast.copy.error')) + return + } + + toast.success(t('toast.copy.success')) } function setDownloadLimit() { diff --git a/src/components/TorrentDetail/Overview.vue b/src/components/TorrentDetail/Overview.vue index 432154a2..cb492d57 100644 --- a/src/components/TorrentDetail/Overview.vue +++ b/src/components/TorrentDetail/Overview.vue @@ -9,6 +9,7 @@ import { Torrent } from '@/types/vuetorrent' import { useIntervalFn } from '@vueuse/core' import { computed, ref, watch, onMounted, onUnmounted } from 'vue' import { useI18n } from 'vue-i18n' +import { toast } from 'vue3-toastify' import { useTheme } from 'vuetify' const props = defineProps<{ torrent: Torrent; isActive: boolean }>() @@ -114,7 +115,14 @@ async function renderTorrentPieceStates() { } async function copyHash() { - await navigator.clipboard.writeText(props.torrent.hash) + try { + await navigator.clipboard.writeText(props.torrent.hash) + } catch (error) { + toast.error(t('toast.copy.error')) + return + } + + toast.success(t('toast.copy.success')) } function openMoveTorrentDialog(mode: 'dl' | 'save') { diff --git a/src/locales/en.json b/src/locales/en.json index 9820a261..c835a2cd 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -1015,6 +1015,10 @@ } }, "toast": { + "copy": { + "error": "Unable to copy, context isn't secured!", + "success": "Copied to clipboard!" + }, "magnet_handler": { "not_supported": "Current context isn't secure. Unable to register handler.", "registered": "Magnet handler registered."