Change syntax to a utils action
This commit is contained in:
parent
cc101fd119
commit
0b988e72b9
|
@ -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'
|
||||
])
|
||||
}
|
||||
})
|
||||
|
|
|
@ -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--) {
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue