diff --git a/src/renderer/App.js b/src/renderer/App.js index d4b97d6d..c5b1115e 100644 --- a/src/renderer/App.js +++ b/src/renderer/App.js @@ -40,7 +40,14 @@ export default Vue.extend({ blogBannerMessage: '', latestBlogUrl: '', updateChangelog: '', - changeLogTitle: '' + changeLogTitle: '', + + lastExternalLinkToBeOpened: '', + showExternalLinkOpeningPrompt: false, + externalLinkOpeningPromptValues: [ + 'yes', + 'no' + ] } }, computed: { @@ -96,6 +103,17 @@ export default Vue.extend({ }, defaultInvidiousInstance: function () { return this.$store.getters.getDefaultInvidiousInstance + }, + + externalLinkOpeningPromptNames: function () { + return [ + this.$t('Yes'), + this.$t('No') + ] + }, + + externalLinkHandling: function () { + return this.$store.getters.getExternalLinkHandling } }, watch: { @@ -309,8 +327,18 @@ export default Vue.extend({ if (isYoutubeLink) { this.handleYoutubeLink(el.href) + } else if (this.externalLinkHandling === 'doNothing') { + // Let user know opening external link is disabled via setting + this.showToast({ + message: this.$t('External link opening has been disabled in the general settings') + }) + } else if (this.externalLinkHandling === 'openLinkAfterPrompt') { + // Storing the URL is necessary as + // there is no other way to pass the URL to click callback + this.lastExternalLinkToBeOpened = el.href + this.showExternalLinkOpeningPrompt = true } else { - // Open links externally by default + // Open links externally this.openExternalLink(el.href) } }) @@ -408,6 +436,18 @@ export default Vue.extend({ ipcRenderer.send('appReady') }, + handleExternalLinkOpeningPromptAnswer: function (option) { + this.showExternalLinkOpeningPrompt = false + + if (option === 'yes' && this.lastExternalLinkToBeOpened.length > 0) { + // Maybe user should be notified + // if `lastExternalLinkToBeOpened` is empty + + // Open links externally + this.openExternalLink(this.lastExternalLinkToBeOpened) + } + }, + ...mapMutations([ 'setInvidiousInstancesList' ]), diff --git a/src/renderer/App.vue b/src/renderer/App.vue index 9187a759..0e5d5db1 100644 --- a/src/renderer/App.vue +++ b/src/renderer/App.vue @@ -57,6 +57,14 @@ /> + { return [] } + }, optionNames: { type: Array, default: () => { return [] } diff --git a/src/renderer/components/ft-prompt/ft-prompt.vue b/src/renderer/components/ft-prompt/ft-prompt.vue index 1c2830fd..da993727 100644 --- a/src/renderer/components/ft-prompt/ft-prompt.vue +++ b/src/renderer/components/ft-prompt/ft-prompt.vue @@ -8,6 +8,15 @@

{{ label }}

+

+ + {{ extraLabel }} + +

+