2020-02-16 18:30:00 +00:00
|
|
|
import Vue from 'vue'
|
2021-07-03 01:55:56 +00:00
|
|
|
import { mapActions, mapMutations } from 'vuex'
|
2020-08-24 19:50:03 +00:00
|
|
|
import { ObserveVisibility } from 'vue-observe-visibility'
|
2020-09-20 18:22:39 +00:00
|
|
|
import FtFlexBox from './components/ft-flex-box/ft-flex-box.vue'
|
2020-02-16 18:30:00 +00:00
|
|
|
import TopNav from './components/top-nav/top-nav.vue'
|
|
|
|
import SideNav from './components/side-nav/side-nav.vue'
|
2020-09-20 18:22:39 +00:00
|
|
|
import FtNotificationBanner from './components/ft-notification-banner/ft-notification-banner.vue'
|
|
|
|
import FtPrompt from './components/ft-prompt/ft-prompt.vue'
|
|
|
|
import FtButton from './components/ft-button/ft-button.vue'
|
2020-06-14 21:13:35 +00:00
|
|
|
import FtToast from './components/ft-toast/ft-toast.vue'
|
2020-08-31 21:35:22 +00:00
|
|
|
import FtProgressBar from './components/ft-progress-bar/ft-progress-bar.vue'
|
2020-02-16 18:30:00 +00:00
|
|
|
import $ from 'jquery'
|
2022-02-06 23:16:46 +00:00
|
|
|
import { marked } from 'marked'
|
2020-09-20 18:22:39 +00:00
|
|
|
import Parser from 'rss-parser'
|
2020-03-24 13:22:29 +00:00
|
|
|
|
2021-05-21 23:49:48 +00:00
|
|
|
let ipcRenderer = null
|
2020-03-24 13:22:29 +00:00
|
|
|
|
2020-08-24 19:50:03 +00:00
|
|
|
Vue.directive('observe-visibility', ObserveVisibility)
|
|
|
|
|
2020-02-16 18:30:00 +00:00
|
|
|
export default Vue.extend({
|
|
|
|
name: 'App',
|
|
|
|
components: {
|
2020-09-20 18:22:39 +00:00
|
|
|
FtFlexBox,
|
2020-02-16 18:30:00 +00:00
|
|
|
TopNav,
|
2020-06-14 21:13:35 +00:00
|
|
|
SideNav,
|
2020-09-20 18:22:39 +00:00
|
|
|
FtNotificationBanner,
|
|
|
|
FtPrompt,
|
|
|
|
FtButton,
|
2020-08-31 21:35:22 +00:00
|
|
|
FtToast,
|
|
|
|
FtProgressBar
|
2020-02-16 18:30:00 +00:00
|
|
|
},
|
2020-09-16 02:55:19 +00:00
|
|
|
data: function () {
|
|
|
|
return {
|
2021-04-20 18:07:47 +00:00
|
|
|
dataReady: false,
|
2020-09-20 18:22:39 +00:00
|
|
|
hideOutlines: true,
|
|
|
|
showUpdatesBanner: false,
|
|
|
|
showBlogBanner: false,
|
|
|
|
showReleaseNotes: false,
|
|
|
|
updateBannerMessage: '',
|
|
|
|
blogBannerMessage: '',
|
|
|
|
latestBlogUrl: '',
|
|
|
|
updateChangelog: '',
|
2021-09-16 23:03:25 +00:00
|
|
|
changeLogTitle: '',
|
|
|
|
lastExternalLinkToBeOpened: '',
|
|
|
|
showExternalLinkOpeningPrompt: false,
|
|
|
|
externalLinkOpeningPromptValues: [
|
|
|
|
'yes',
|
|
|
|
'no'
|
|
|
|
]
|
2020-09-16 02:55:19 +00:00
|
|
|
}
|
|
|
|
},
|
2020-02-16 18:30:00 +00:00
|
|
|
computed: {
|
2020-10-22 18:56:49 +00:00
|
|
|
isDev: function () {
|
|
|
|
return process.env.NODE_ENV === 'development'
|
|
|
|
},
|
2020-02-16 18:30:00 +00:00
|
|
|
isOpen: function () {
|
|
|
|
return this.$store.getters.getIsSideNavOpen
|
2020-08-31 21:35:22 +00:00
|
|
|
},
|
2021-06-06 17:13:36 +00:00
|
|
|
usingElectron: function() {
|
|
|
|
return this.$store.getters.getUsingElectron
|
|
|
|
},
|
2020-08-31 21:35:22 +00:00
|
|
|
showProgressBar: function () {
|
|
|
|
return this.$store.getters.getShowProgressBar
|
2020-09-16 13:51:26 +00:00
|
|
|
},
|
|
|
|
isRightAligned: function () {
|
|
|
|
return this.$i18n.locale === 'ar'
|
2020-09-20 18:22:39 +00:00
|
|
|
},
|
|
|
|
checkForUpdates: function () {
|
|
|
|
return this.$store.getters.getCheckForUpdates
|
|
|
|
},
|
|
|
|
checkForBlogPosts: function () {
|
|
|
|
return this.$store.getters.getCheckForBlogPosts
|
2020-10-04 20:31:07 +00:00
|
|
|
},
|
|
|
|
searchSettings: function () {
|
|
|
|
return this.$store.getters.getSearchSettings
|
2020-10-06 13:38:35 +00:00
|
|
|
},
|
|
|
|
profileList: function () {
|
|
|
|
return this.$store.getters.getProfileList
|
|
|
|
},
|
2021-07-21 15:45:02 +00:00
|
|
|
windowTitle: function () {
|
|
|
|
if (this.$route.meta.title !== 'Channel' && this.$route.meta.title !== 'Watch') {
|
|
|
|
let title =
|
|
|
|
this.$route.meta.path === '/home'
|
|
|
|
? process.env.PRODUCT_NAME
|
|
|
|
: `${this.$t(this.$route.meta.title)} - ${process.env.PRODUCT_NAME}`
|
|
|
|
if (!title) {
|
|
|
|
title = process.env.PRODUCT_NAME
|
|
|
|
}
|
|
|
|
return title
|
|
|
|
} else {
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
},
|
2020-10-06 13:38:35 +00:00
|
|
|
defaultProfile: function () {
|
|
|
|
return this.$store.getters.getDefaultProfile
|
2021-06-13 15:31:43 +00:00
|
|
|
},
|
|
|
|
externalPlayer: function () {
|
|
|
|
return this.$store.getters.getExternalPlayer
|
2021-07-03 01:55:56 +00:00
|
|
|
},
|
|
|
|
defaultInvidiousInstance: function () {
|
|
|
|
return this.$store.getters.getDefaultInvidiousInstance
|
2021-09-16 23:03:25 +00:00
|
|
|
},
|
|
|
|
|
2022-03-05 08:09:32 +00:00
|
|
|
baseTheme: function () {
|
|
|
|
return this.$store.getters.getBaseTheme
|
|
|
|
},
|
|
|
|
|
|
|
|
mainColor: function () {
|
|
|
|
return this.$store.getters.getMainColor
|
|
|
|
},
|
|
|
|
|
|
|
|
secColor: function () {
|
|
|
|
return this.$store.getters.getSecColor
|
|
|
|
},
|
|
|
|
|
2021-09-16 23:03:25 +00:00
|
|
|
externalLinkOpeningPromptNames: function () {
|
|
|
|
return [
|
|
|
|
this.$t('Yes'),
|
|
|
|
this.$t('No')
|
|
|
|
]
|
|
|
|
},
|
|
|
|
|
|
|
|
externalLinkHandling: function () {
|
|
|
|
return this.$store.getters.getExternalLinkHandling
|
2020-02-16 18:30:00 +00:00
|
|
|
}
|
|
|
|
},
|
2021-07-21 15:45:02 +00:00
|
|
|
watch: {
|
2021-09-13 17:26:08 +00:00
|
|
|
windowTitle: 'setWindowTitle',
|
2022-03-05 08:09:32 +00:00
|
|
|
|
|
|
|
baseTheme: 'checkThemeSettings',
|
|
|
|
|
|
|
|
mainColor: 'checkThemeSettings',
|
|
|
|
|
|
|
|
secColor: 'checkThemeSettings',
|
|
|
|
|
2021-09-13 17:26:08 +00:00
|
|
|
$route () {
|
|
|
|
// react to route changes...
|
|
|
|
// Hide top nav filter panel on page change
|
|
|
|
this.$refs.topNav.hideFilters()
|
|
|
|
}
|
2021-07-21 15:45:02 +00:00
|
|
|
},
|
|
|
|
created () {
|
2021-10-01 12:12:35 +00:00
|
|
|
this.checkThemeSettings()
|
2021-07-21 15:45:02 +00:00
|
|
|
this.setWindowTitle()
|
|
|
|
},
|
2020-02-16 18:30:00 +00:00
|
|
|
mounted: function () {
|
2021-07-03 01:55:56 +00:00
|
|
|
this.grabUserSettings().then(async () => {
|
2021-11-02 11:42:24 +00:00
|
|
|
await this.fetchInvidiousInstances({ isDev: this.isDev })
|
2021-07-03 01:55:56 +00:00
|
|
|
if (this.defaultInvidiousInstance === '') {
|
|
|
|
await this.setRandomCurrentInvidiousInstance()
|
|
|
|
}
|
|
|
|
|
2021-05-21 23:56:32 +00:00
|
|
|
this.grabAllProfiles(this.$t('Profile.All Channels')).then(async () => {
|
|
|
|
this.grabHistory()
|
|
|
|
this.grabAllPlaylists()
|
2020-02-27 03:10:56 +00:00
|
|
|
|
2021-06-06 17:13:36 +00:00
|
|
|
if (this.usingElectron) {
|
2021-04-20 18:07:47 +00:00
|
|
|
console.log('User is using Electron')
|
2021-06-06 17:13:36 +00:00
|
|
|
ipcRenderer = require('electron').ipcRenderer
|
Store Revamp / Full database synchronization across windows (#1833)
* History: Refactor history module
* Profiles: Refactor profiles module
* IPC: Move channel ids to their own file and make them constants
* IPC: Replace single sync channel for one channel per sync type
* Everywhere: Replace default profile id magic strings with constant ref
* Profiles: Refactor `activeProfile` property from store
This commit makes it so that `activeProfile`'s getter returns
the entire profile, while the related update function only needs
the profile id (instead of the previously used array index)
to change the currently active profile.
This change was made due to inconsistency regarding the active profile
when creating new profiles.
If a new profile coincidentally landed in the current active profile's
array index after sorting, the app would mistakenly change to it
without any action from the user apart from the profile's creation.
Turning the profile id into the selector instead solves this issue.
* Revert "Store: Implement history synchronization between windows"
This reverts commit 99b61e617873412eb393d8f4dfccd8f8c172021f.
This is necessary for an upcoming improved implementation of the
history synchronization.
* History: Remove unused mutation
* Everywhere: Create abstract database handlers
The project now utilizes abstract handlers to fetch, modify
or otherwise manipulate data from the database.
This facilitates 3 aspects of the app, in addition of
making them future proof:
- Switching database libraries is now trivial
Since most of the app utilizes the abstract handlers, it's incredibly
easily to change to a different DB library.
Hypothetically, all that would need to be done is to simply replace the
the file containing the base handlers, while the rest of the app
would go unchanged.
- Syncing logic between Electron and web is now properly separated
There are now two distinct DB handling APIs: the Electron one and
the web one.
The app doesn't need to manually choose the API, because it's detected
which platform is being utilized on import.
- All Electron windows now share the same database instance
This provides a single source of truth, improving consistency
regarding data manipulation and windows synchronization.
As a sidenote, syncing implementation has been left as is
(web unimplemented; Electron only syncs settings, remaining
datastore syncing will be implemented in the upcoming commits).
* Electron/History: Implement history synchronization
* Profiles: Implement suplementary profile creation logic
* ft-profile-edit: Small fix on profile name missing display
* Electron/Profiles: Implement profile synchronization
* Electron/Playlists: Implement playlist synchronization
2021-12-15 18:42:24 +00:00
|
|
|
this.setupListenersToSyncWindows()
|
2021-04-20 18:07:47 +00:00
|
|
|
this.activateKeyboardShortcuts()
|
|
|
|
this.openAllLinksExternally()
|
|
|
|
this.enableOpenUrl()
|
2021-06-13 15:31:43 +00:00
|
|
|
await this.checkExternalPlayer()
|
2021-04-20 18:07:47 +00:00
|
|
|
}
|
2020-09-20 18:22:39 +00:00
|
|
|
|
2021-06-13 15:31:43 +00:00
|
|
|
this.dataReady = true
|
|
|
|
|
2021-04-20 18:07:47 +00:00
|
|
|
setTimeout(() => {
|
|
|
|
this.checkForNewUpdates()
|
|
|
|
this.checkForNewBlogPosts()
|
|
|
|
}, 500)
|
|
|
|
})
|
2021-09-16 22:58:03 +00:00
|
|
|
|
|
|
|
this.$router.afterEach((to, from) => {
|
|
|
|
this.$refs.topNav.navigateHistory()
|
|
|
|
})
|
2021-03-14 19:18:46 +00:00
|
|
|
})
|
2020-06-01 02:10:29 +00:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
checkThemeSettings: function () {
|
|
|
|
const theme = {
|
2022-03-05 08:09:32 +00:00
|
|
|
baseTheme: this.baseTheme || 'dark',
|
|
|
|
mainColor: this.mainColor || 'mainRed',
|
|
|
|
secColor: this.secColor || 'secBlue'
|
2020-06-01 02:10:29 +00:00
|
|
|
}
|
2020-03-01 03:37:02 +00:00
|
|
|
|
2020-06-01 02:10:29 +00:00
|
|
|
this.updateTheme(theme)
|
|
|
|
},
|
2020-03-24 13:22:29 +00:00
|
|
|
|
2020-02-27 03:10:56 +00:00
|
|
|
updateTheme: function (theme) {
|
2022-03-05 08:09:32 +00:00
|
|
|
console.group('updateTheme')
|
|
|
|
console.log('Theme: ', theme)
|
|
|
|
const className = `${theme.baseTheme} main${theme.mainColor} sec${theme.secColor}`
|
2020-02-27 03:10:56 +00:00
|
|
|
const body = document.getElementsByTagName('body')[0]
|
2020-03-01 03:37:02 +00:00
|
|
|
body.className = className
|
2022-03-05 08:09:32 +00:00
|
|
|
console.groupEnd()
|
2020-06-01 02:10:29 +00:00
|
|
|
},
|
|
|
|
|
2020-09-20 18:22:39 +00:00
|
|
|
checkForNewUpdates: function () {
|
|
|
|
if (this.checkForUpdates) {
|
|
|
|
const { version } = require('../../package.json')
|
2022-04-08 02:03:28 +00:00
|
|
|
const requestUrl = 'https://api.github.com/repos/freetubeapp/freetube/releases?per_page=1'
|
2020-09-20 18:22:39 +00:00
|
|
|
|
|
|
|
$.getJSON(requestUrl, (response) => {
|
|
|
|
const tagName = response[0].tag_name
|
|
|
|
const versionNumber = tagName.replace('v', '').replace('-beta', '')
|
2022-02-06 23:16:46 +00:00
|
|
|
this.updateChangelog = marked.parse(response[0].body)
|
2020-09-20 18:22:39 +00:00
|
|
|
this.changeLogTitle = response[0].name
|
|
|
|
|
|
|
|
const message = this.$t('Version $ is now available! Click for more details')
|
|
|
|
this.updateBannerMessage = message.replace('$', versionNumber)
|
2020-12-18 16:57:20 +00:00
|
|
|
|
|
|
|
const appVersion = version.split('.')
|
|
|
|
const latestVersion = versionNumber.split('.')
|
|
|
|
|
|
|
|
if (parseInt(appVersion[0]) < parseInt(latestVersion[0])) {
|
|
|
|
this.showUpdatesBanner = true
|
|
|
|
} else if (parseInt(appVersion[1]) < parseInt(latestVersion[1])) {
|
|
|
|
this.showUpdatesBanner = true
|
2021-09-01 20:31:20 +00:00
|
|
|
} else if (parseInt(appVersion[2]) < parseInt(latestVersion[2]) && parseInt(appVersion[1]) <= parseInt(latestVersion[1])) {
|
2020-09-20 18:22:39 +00:00
|
|
|
this.showUpdatesBanner = true
|
|
|
|
}
|
|
|
|
}).fail((xhr, textStatus, error) => {
|
|
|
|
console.log(xhr)
|
|
|
|
console.log(textStatus)
|
|
|
|
console.log(requestUrl)
|
|
|
|
console.log(error)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
checkForNewBlogPosts: function () {
|
|
|
|
if (this.checkForBlogPosts) {
|
|
|
|
const parser = new Parser()
|
|
|
|
const feedUrl = 'https://write.as/freetube/feed/'
|
|
|
|
let lastAppWasRunning = localStorage.getItem('lastAppWasRunning')
|
|
|
|
|
|
|
|
if (lastAppWasRunning !== null) {
|
|
|
|
lastAppWasRunning = new Date(lastAppWasRunning)
|
|
|
|
}
|
|
|
|
|
|
|
|
parser.parseURL(feedUrl).then((response) => {
|
|
|
|
const latestBlog = response.items[0]
|
|
|
|
const latestPubDate = new Date(latestBlog.pubDate)
|
|
|
|
|
|
|
|
if (lastAppWasRunning === null || latestPubDate > lastAppWasRunning) {
|
|
|
|
const message = this.$t('A new blog is now available, $. Click to view more')
|
|
|
|
this.blogBannerMessage = message.replace('$', latestBlog.title)
|
|
|
|
this.latestBlogUrl = latestBlog.link
|
|
|
|
this.showBlogBanner = true
|
|
|
|
}
|
|
|
|
|
|
|
|
localStorage.setItem('lastAppWasRunning', new Date())
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2021-06-13 15:31:43 +00:00
|
|
|
checkExternalPlayer: async function () {
|
|
|
|
const payload = {
|
|
|
|
isDev: this.isDev,
|
|
|
|
externalPlayer: this.externalPlayer
|
|
|
|
}
|
|
|
|
this.getExternalPlayerCmdArgumentsData(payload)
|
|
|
|
},
|
|
|
|
|
2020-09-20 18:22:39 +00:00
|
|
|
handleUpdateBannerClick: function (response) {
|
|
|
|
if (response !== false) {
|
|
|
|
this.showReleaseNotes = true
|
|
|
|
} else {
|
|
|
|
this.showUpdatesBanner = false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
handleNewBlogBannerClick: function (response) {
|
|
|
|
if (response) {
|
2021-05-21 23:49:48 +00:00
|
|
|
this.openExternalLink(this.latestBlogUrl)
|
2020-09-20 18:22:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
this.showBlogBanner = false
|
|
|
|
},
|
|
|
|
|
|
|
|
openDownloadsPage: function () {
|
|
|
|
const url = 'https://freetubeapp.io#download'
|
2021-05-21 23:49:48 +00:00
|
|
|
this.openExternalLink(url)
|
2020-09-20 18:22:39 +00:00
|
|
|
this.showReleaseNotes = false
|
|
|
|
this.showUpdatesBanner = false
|
|
|
|
},
|
|
|
|
|
2020-06-01 02:10:29 +00:00
|
|
|
activateKeyboardShortcuts: function () {
|
|
|
|
$(document).on('keydown', this.handleKeyboardShortcuts)
|
2020-09-16 02:55:19 +00:00
|
|
|
$(document).on('mousedown', () => {
|
|
|
|
this.hideOutlines = true
|
|
|
|
})
|
2020-06-01 02:10:29 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
handleKeyboardShortcuts: function (event) {
|
|
|
|
if (event.altKey) {
|
|
|
|
switch (event.code) {
|
|
|
|
case 'ArrowRight':
|
2021-09-16 22:58:03 +00:00
|
|
|
this.$refs.topNav.historyForward()
|
2020-06-01 02:10:29 +00:00
|
|
|
break
|
|
|
|
case 'ArrowLeft':
|
2021-09-16 22:58:03 +00:00
|
|
|
this.$refs.topNav.historyBack()
|
2020-06-01 02:10:29 +00:00
|
|
|
break
|
2022-04-08 02:45:22 +00:00
|
|
|
case 'KeyD':
|
|
|
|
this.$refs.topNav.focusSearch()
|
|
|
|
break
|
2020-06-01 02:10:29 +00:00
|
|
|
}
|
|
|
|
}
|
2020-09-16 02:55:19 +00:00
|
|
|
switch (event.code) {
|
|
|
|
case 'Tab':
|
|
|
|
this.hideOutlines = false
|
|
|
|
break
|
2022-04-09 19:43:17 +00:00
|
|
|
case 'KeyL':
|
|
|
|
if ((process.platform !== 'darwin' && event.ctrlKey) ||
|
|
|
|
(process.platform === 'darwin' && event.metaKey)) {
|
|
|
|
this.$refs.topNav.focusSearch()
|
|
|
|
}
|
|
|
|
break
|
2020-09-16 02:55:19 +00:00
|
|
|
}
|
2020-06-01 02:10:29 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
openAllLinksExternally: function () {
|
|
|
|
$(document).on('click', 'a[href^="http"]', (event) => {
|
2022-01-11 02:16:50 +00:00
|
|
|
this.handleLinkClick(event)
|
2021-03-30 02:32:17 +00:00
|
|
|
})
|
2022-01-11 02:16:50 +00:00
|
|
|
|
|
|
|
$(document).on('auxclick', 'a[href^="http"]', (event) => {
|
|
|
|
this.handleLinkClick(event)
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
handleLinkClick: function (event) {
|
|
|
|
const el = event.currentTarget
|
|
|
|
console.log(this.usingElectron)
|
|
|
|
console.log(el)
|
|
|
|
event.preventDefault()
|
|
|
|
|
|
|
|
// Check if it's a YouTube link
|
|
|
|
const youtubeUrlPattern = /^https?:\/\/((www\.)?youtube\.com(\/embed)?|youtu\.be)\/.*$/
|
|
|
|
const isYoutubeLink = youtubeUrlPattern.test(el.href)
|
|
|
|
|
|
|
|
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
|
|
|
|
this.openExternalLink(el.href)
|
|
|
|
}
|
2021-03-30 02:32:17 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
handleYoutubeLink: function (href) {
|
2021-05-21 23:56:32 +00:00
|
|
|
this.getYoutubeUrlInfo(href).then((result) => {
|
2021-04-28 17:21:16 +00:00
|
|
|
switch (result.urlType) {
|
|
|
|
case 'video': {
|
2021-05-31 11:23:35 +00:00
|
|
|
const { videoId, timestamp, playlistId } = result
|
|
|
|
|
|
|
|
const query = {}
|
|
|
|
if (timestamp) {
|
|
|
|
query.timestamp = timestamp
|
|
|
|
}
|
|
|
|
if (playlistId && playlistId.length > 0) {
|
|
|
|
query.playlistId = playlistId
|
|
|
|
}
|
2021-04-28 17:21:16 +00:00
|
|
|
this.$router.push({
|
|
|
|
path: `/watch/${videoId}`,
|
2021-05-31 11:23:35 +00:00
|
|
|
query: query
|
2021-04-28 17:21:16 +00:00
|
|
|
})
|
|
|
|
break
|
|
|
|
}
|
2021-03-30 02:32:17 +00:00
|
|
|
|
2021-04-28 17:21:16 +00:00
|
|
|
case 'playlist': {
|
|
|
|
const { playlistId, query } = result
|
|
|
|
|
|
|
|
this.$router.push({
|
|
|
|
path: `/playlist/${playlistId}`,
|
|
|
|
query
|
|
|
|
})
|
|
|
|
break
|
2021-03-30 02:32:17 +00:00
|
|
|
}
|
|
|
|
|
2021-04-28 17:21:16 +00:00
|
|
|
case 'search': {
|
|
|
|
const { searchQuery, query } = result
|
2021-03-30 02:32:17 +00:00
|
|
|
|
2021-04-28 17:21:16 +00:00
|
|
|
this.$router.push({
|
|
|
|
path: `/search/${encodeURIComponent(searchQuery)}`,
|
|
|
|
query
|
|
|
|
})
|
|
|
|
break
|
|
|
|
}
|
2021-04-25 00:28:29 +00:00
|
|
|
|
2021-04-28 17:21:16 +00:00
|
|
|
case 'hashtag': {
|
|
|
|
// TODO: Implement a hashtag related view
|
|
|
|
let message = 'Hashtags have not yet been implemented, try again later'
|
|
|
|
if (this.$te(message) && this.$t(message) !== '') {
|
|
|
|
message = this.$t(message)
|
2021-04-25 00:28:29 +00:00
|
|
|
}
|
|
|
|
|
2021-04-28 17:21:16 +00:00
|
|
|
this.showToast({
|
|
|
|
message: message
|
|
|
|
})
|
|
|
|
break
|
|
|
|
}
|
2021-03-30 02:32:17 +00:00
|
|
|
|
2021-04-28 17:21:16 +00:00
|
|
|
case 'channel': {
|
2021-11-02 11:45:50 +00:00
|
|
|
const { channelId, subPath } = result
|
2021-04-28 17:21:16 +00:00
|
|
|
|
|
|
|
this.$router.push({
|
2021-11-02 11:45:50 +00:00
|
|
|
path: `/channel/${channelId}/${subPath}`
|
2021-04-28 17:21:16 +00:00
|
|
|
})
|
|
|
|
break
|
|
|
|
}
|
2021-03-30 02:32:17 +00:00
|
|
|
|
2021-04-28 17:21:16 +00:00
|
|
|
case 'invalid_url': {
|
|
|
|
// Do nothing
|
|
|
|
break
|
|
|
|
}
|
2021-04-25 00:28:29 +00:00
|
|
|
|
2021-04-28 17:21:16 +00:00
|
|
|
default: {
|
|
|
|
// Unknown URL type
|
|
|
|
let message = 'Unknown YouTube url type, cannot be opened in app'
|
|
|
|
if (this.$te(message) && this.$t(message) !== '') {
|
|
|
|
message = this.$t(message)
|
2021-03-30 02:32:17 +00:00
|
|
|
}
|
2021-04-28 17:21:16 +00:00
|
|
|
|
|
|
|
this.showToast({
|
|
|
|
message: message
|
|
|
|
})
|
2021-03-30 02:32:17 +00:00
|
|
|
}
|
2020-06-01 02:10:29 +00:00
|
|
|
}
|
|
|
|
})
|
2020-09-20 18:54:23 +00:00
|
|
|
},
|
|
|
|
|
2020-10-15 13:33:25 +00:00
|
|
|
enableOpenUrl: function () {
|
2021-05-21 23:52:11 +00:00
|
|
|
ipcRenderer.on('openUrl', (event, url) => {
|
2020-10-04 20:31:07 +00:00
|
|
|
if (url) {
|
2021-05-21 23:52:11 +00:00
|
|
|
this.handleYoutubeLink(url)
|
2020-10-04 20:31:07 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2021-05-21 23:49:48 +00:00
|
|
|
ipcRenderer.send('appReady')
|
2020-10-04 20:31:07 +00:00
|
|
|
},
|
|
|
|
|
2021-09-16 23:03:25 +00:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2021-07-21 15:45:02 +00:00
|
|
|
setWindowTitle: function() {
|
|
|
|
if (this.windowTitle !== null) {
|
|
|
|
document.title = this.windowTitle
|
|
|
|
}
|
|
|
|
},
|
2022-01-11 02:16:50 +00:00
|
|
|
|
|
|
|
...mapMutations([
|
|
|
|
'setInvidiousInstancesList'
|
|
|
|
]),
|
|
|
|
|
2021-04-25 00:28:29 +00:00
|
|
|
...mapActions([
|
2021-05-21 23:49:48 +00:00
|
|
|
'showToast',
|
2021-05-21 23:56:32 +00:00
|
|
|
'openExternalLink',
|
|
|
|
'grabUserSettings',
|
|
|
|
'grabAllProfiles',
|
|
|
|
'grabHistory',
|
|
|
|
'grabAllPlaylists',
|
2021-05-25 17:39:34 +00:00
|
|
|
'getYoutubeUrlInfo',
|
2021-06-13 15:31:43 +00:00
|
|
|
'getExternalPlayerCmdArgumentsData',
|
2021-07-03 01:55:56 +00:00
|
|
|
'fetchInvidiousInstances',
|
|
|
|
'setRandomCurrentInvidiousInstance',
|
2022-03-05 08:09:32 +00:00
|
|
|
'setupListenersToSyncWindows',
|
|
|
|
'updateBaseTheme',
|
|
|
|
'updateMainColor',
|
|
|
|
'updateSecColor'
|
2021-04-25 00:28:29 +00:00
|
|
|
])
|
2020-02-16 18:30:00 +00:00
|
|
|
}
|
|
|
|
})
|