diff --git a/src/renderer/components/top-nav/top-nav.js b/src/renderer/components/top-nav/top-nav.js index df8d3a8f..224348b2 100644 --- a/src/renderer/components/top-nav/top-nav.js +++ b/src/renderer/components/top-nav/top-nav.js @@ -59,17 +59,27 @@ export default Vue.extend({ searchContainer.style.display = 'none' } - router.push( - { - path: `/search/${query}`, - query: { - sortBy: this.searchSettings.sortBy, - time: this.searchSettings.time, - type: this.searchSettings.type, - duration: this.searchSettings.duration - } + this.$store.dispatch('getVideoIdFromUrl', query).then((result) => { + if (result) { + this.$router.push( + { + path: `/watch/${result}`, + } + ) + } else { + router.push( + { + path: `/search/${query}`, + query: { + sortBy: this.searchSettings.sortBy, + time: this.searchSettings.time, + type: this.searchSettings.type, + duration: this.searchSettings.duration + } + } + ) } - ) + }) this.showFilters = false }, diff --git a/src/renderer/components/watch-video-live-chat/watch-video-live-chat.js b/src/renderer/components/watch-video-live-chat/watch-video-live-chat.js index fae96b6a..259732c8 100644 --- a/src/renderer/components/watch-video-live-chat/watch-video-live-chat.js +++ b/src/renderer/components/watch-video-live-chat/watch-video-live-chat.js @@ -220,9 +220,6 @@ export default Vue.extend({ onScroll: function (event) { const liveChatComments = $('.liveChatComments').get(0) - const scrollTop = liveChatComments.scrollTop - const scrollHeight = liveChatComments.scrollHeight - const clientHeight = liveChatComments.clientHeight if (event.wheelDelta >= 0 && this.stayAtBottom) { $('.liveChatComments').data('animating', 0) this.stayAtBottom = false diff --git a/src/renderer/store/modules/utils.js b/src/renderer/store/modules/utils.js index c45e956b..5cfe4080 100644 --- a/src/renderer/store/modules/utils.js +++ b/src/renderer/store/modules/utils.js @@ -51,6 +51,20 @@ const actions = { getRandomColorClass () { const randomInt = Math.floor(Math.random() * state.colorClasses.length) return state.colorClasses[randomInt] + }, + + getVideoIdFromUrl ({ state }, url) { + console.log('checking for id') + console.log(url) + const rx = /^.*(?:(?:(you|hook)tu\.?be\/|v\/|vi\/|u\/\w\/|embed\/)|(?:(?:watch)?\?v(?:i)?=|\&v(?:i)?=))([^#\&\?]*).*/ + + const match = url.match(rx) + + if (match) { + return match[2] + } else { + return false + } } }