fix(clipboard): Add missing toast on clipboard action (#1452)

This commit is contained in:
Rémi Marseault 2024-01-13 07:51:37 +01:00 committed by GitHub
parent 2711307a12
commit 9b81865ded
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 2 deletions

View file

@ -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() {

View file

@ -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') {

View file

@ -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."