Skip to content

Commit

Permalink
fix(clipboard): Add missing toast on clipboard action (#1452)
Browse files Browse the repository at this point in the history
  • Loading branch information
Larsluph authored Jan 13, 2024
1 parent 2711307 commit 9b81865
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/components/Dashboard/TRC/RightClickMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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() {
Expand Down
10 changes: 9 additions & 1 deletion src/components/TorrentDetail/Overview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 }>()
Expand Down Expand Up @@ -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') {
Expand Down
4 changes: 4 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down

0 comments on commit 9b81865

Please sign in to comment.