diff --git a/src/renderer/components/ft-share-button/ft-share-button.js b/src/renderer/components/ft-share-button/ft-share-button.js index cc897cd7..8da6f680 100644 --- a/src/renderer/components/ft-share-button/ft-share-button.js +++ b/src/renderer/components/ft-share-button/ft-share-button.js @@ -2,7 +2,7 @@ import Vue from 'vue' import FtIconButton from '../ft-icon-button/ft-icon-button.vue' import FtButton from '../ft-button/ft-button.vue' -import FtToastEvents from '../ft-toast/ft-toast-events' +import { mapActions } from 'vuex' export default Vue.extend({ name: 'FtShareButton', @@ -60,7 +60,7 @@ export default Vue.extend({ }, copyInvidious() { - FtToastEvents.$emit('toast.open', 'Invidious URL copied to clipboard') + this.showToast('Invidious URL copied to clipboard') this.copy(this.invidiousURL) this.$refs.iconButton.toggleDropdown() }, @@ -71,7 +71,7 @@ export default Vue.extend({ }, copyYoutube() { - FtToastEvents.$emit('toast.open', 'YouTube URL copied to clipboard') + this.showToast('YouTube URL copied to clipboard') this.copy(this.youtubeURL) this.$refs.iconButton.toggleDropdown() }, @@ -82,7 +82,7 @@ export default Vue.extend({ }, copyYoutubeEmbed() { - FtToastEvents.$emit('toast.open', 'YouTube Embed URL copied to clipboard') + this.showToast('YouTube Embed URL copied to clipboard') this.copy(this.youtubeEmbedURL) this.$refs.iconButton.toggleDropdown() }, @@ -93,9 +93,13 @@ export default Vue.extend({ }, copyInvidiousEmbed() { - FtToastEvents.$emit('toast.open', 'Invidious Embed URL copied to clipboard') + this.showToast('Invidious Embed URL copied to clipboard') this.copy(this.invidiousEmbedURL) this.$refs.iconButton.toggleDropdown() }, + + ...mapActions([ + 'showToast' + ]) } }) diff --git a/src/renderer/components/ft-toast/ft-toast.js b/src/renderer/components/ft-toast/ft-toast.js index 16cd4aca..14dc3c8a 100644 --- a/src/renderer/components/ft-toast/ft-toast.js +++ b/src/renderer/components/ft-toast/ft-toast.js @@ -30,9 +30,9 @@ export default Vue.extend({ toast.isOpen = false }, - open: function (message, action) { + open: function (message, action, time) { const toast = { message: message, action: action || (() => { }), isOpen: false, timeout: null } - toast.timeout = setTimeout(this.close, 5000, toast) + toast.timeout = setTimeout(this.close, time || 3000, toast) setImmediate(() => toast.isOpen = true) if (this.toasts.length > 4) { for (let i = this.toasts.length - 1; i >= 0; i--) { diff --git a/src/renderer/store/modules/utils.js b/src/renderer/store/modules/utils.js index 680fb7c8..19243798 100644 --- a/src/renderer/store/modules/utils.js +++ b/src/renderer/store/modules/utils.js @@ -1,5 +1,5 @@ import IsEqual from 'lodash.isequal' - +import FtToastEvents from '../../components/ft-toast/ft-toast-events' const state = { isSideNavOpen: false, sessionSearchHistory: [], @@ -84,6 +84,10 @@ const actions = { ] return extractors.reduce((a, c) => a || c(), null) || false + }, + + showToast (_, message, action, time) { + FtToastEvents.$emit('toast.open', message, action, time) } }