2020-02-16 19:30:00 +01:00
|
|
|
import Vue from 'vue'
|
2020-08-05 05:44:34 +02:00
|
|
|
import { mapActions } from 'vuex'
|
2020-02-16 19:30:00 +01:00
|
|
|
import FtCard from '../ft-card/ft-card.vue'
|
|
|
|
import FtButton from '../ft-button/ft-button.vue'
|
|
|
|
import FtListDropdown from '../ft-list-dropdown/ft-list-dropdown.vue'
|
|
|
|
import FtFlexBox from '../ft-flex-box/ft-flex-box.vue'
|
2020-06-06 05:15:44 +02:00
|
|
|
import FtIconButton from '../ft-icon-button/ft-icon-button.vue'
|
2020-06-17 14:15:36 +02:00
|
|
|
import FtShareButton from '../ft-share-button/ft-share-button.vue'
|
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 19:42:24 +01:00
|
|
|
import { MAIN_PROFILE_ID } from '../../../constants'
|
2020-02-16 19:30:00 +01:00
|
|
|
|
|
|
|
export default Vue.extend({
|
|
|
|
name: 'WatchVideoInfo',
|
|
|
|
components: {
|
|
|
|
'ft-card': FtCard,
|
|
|
|
'ft-button': FtButton,
|
|
|
|
'ft-list-dropdown': FtListDropdown,
|
2020-06-06 05:15:44 +02:00
|
|
|
'ft-flex-box': FtFlexBox,
|
2020-06-17 14:15:36 +02:00
|
|
|
'ft-icon-button': FtIconButton,
|
|
|
|
'ft-share-button': FtShareButton
|
2020-02-16 19:30:00 +01:00
|
|
|
},
|
|
|
|
props: {
|
|
|
|
id: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
title: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
channelId: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
channelName: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
channelThumbnail: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
},
|
2020-06-16 23:42:38 +02:00
|
|
|
published: {
|
|
|
|
type: Number,
|
|
|
|
required: true
|
|
|
|
},
|
2020-02-16 19:30:00 +01:00
|
|
|
viewCount: {
|
|
|
|
type: Number,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
subscriptionCountText: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
likeCount: {
|
|
|
|
type: Number,
|
2020-05-17 22:12:58 +02:00
|
|
|
default: 0
|
2020-02-16 19:30:00 +01:00
|
|
|
},
|
|
|
|
dislikeCount: {
|
|
|
|
type: Number,
|
2020-05-17 22:12:58 +02:00
|
|
|
default: 0
|
2020-09-11 05:48:06 +02:00
|
|
|
},
|
2020-09-12 05:20:26 +02:00
|
|
|
getTimestamp: {
|
|
|
|
type: Function,
|
|
|
|
required: true
|
2020-09-16 04:07:54 +02:00
|
|
|
},
|
2020-10-31 15:57:51 +01:00
|
|
|
isLive: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false
|
|
|
|
},
|
|
|
|
isLiveContent: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true
|
|
|
|
},
|
2020-09-16 04:07:54 +02:00
|
|
|
isUpcoming: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true
|
2020-10-08 21:01:46 +02:00
|
|
|
},
|
|
|
|
downloadLinks: {
|
|
|
|
type: Array,
|
|
|
|
required: true
|
2021-01-13 05:13:36 +01:00
|
|
|
},
|
|
|
|
watchingPlaylist: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true
|
|
|
|
},
|
2021-05-25 19:39:34 +02:00
|
|
|
playlistId: {
|
|
|
|
type: String,
|
2021-06-13 17:31:43 +02:00
|
|
|
default: null
|
|
|
|
},
|
|
|
|
getPlaylistIndex: {
|
|
|
|
type: Function,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
getPlaylistReverse: {
|
|
|
|
type: Function,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
getPlaylistShuffle: {
|
|
|
|
type: Function,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
getPlaylistLoop: {
|
|
|
|
type: Function,
|
|
|
|
required: true
|
2021-05-25 19:39:34 +02:00
|
|
|
},
|
2021-01-13 05:13:36 +01:00
|
|
|
theatrePossible: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true
|
2021-01-15 00:03:23 +01:00
|
|
|
},
|
|
|
|
lengthSeconds: {
|
|
|
|
type: Number,
|
|
|
|
required: true
|
2021-02-22 04:07:50 +01:00
|
|
|
},
|
|
|
|
videoThumbnail: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
2020-02-16 19:30:00 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
data: function () {
|
|
|
|
return {
|
|
|
|
formatTypeLabel: 'VIDEO FORMATS',
|
|
|
|
formatTypeValues: [
|
|
|
|
'dash',
|
|
|
|
'legacy',
|
2020-06-01 04:47:22 +02:00
|
|
|
'audio'
|
2020-02-16 19:30:00 +01:00
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
2021-07-03 03:55:56 +02:00
|
|
|
currentInvidiousInstance: function () {
|
|
|
|
return this.$store.getters.getCurrentInvidiousInstance
|
2020-02-16 19:30:00 +01:00
|
|
|
},
|
|
|
|
|
2021-10-02 17:43:42 +02:00
|
|
|
currentLocale: function () {
|
|
|
|
return this.$store.getters.getCurrentLocale
|
|
|
|
},
|
|
|
|
|
2020-08-31 23:35:22 +02:00
|
|
|
profileList: function () {
|
|
|
|
return this.$store.getters.getProfileList
|
|
|
|
},
|
|
|
|
|
|
|
|
activeProfile: function () {
|
|
|
|
return this.$store.getters.getActiveProfile
|
|
|
|
},
|
|
|
|
|
2020-10-06 15:38:35 +02:00
|
|
|
hideRecommendedVideos: function () {
|
|
|
|
return this.$store.getters.getHideRecommendedVideos
|
|
|
|
},
|
|
|
|
|
2021-01-13 05:13:36 +01:00
|
|
|
hideLiveChat: function () {
|
|
|
|
return this.$store.getters.getHideLiveChat
|
|
|
|
},
|
|
|
|
|
2020-10-08 21:01:46 +02:00
|
|
|
hideVideoLikesAndDislikes: function () {
|
|
|
|
return this.$store.getters.getHideVideoLikesAndDislikes
|
|
|
|
},
|
|
|
|
|
|
|
|
hideVideoViews: function () {
|
|
|
|
return this.$store.getters.getHideVideoViews
|
|
|
|
},
|
|
|
|
|
2021-01-15 00:03:23 +01:00
|
|
|
favoritesPlaylist: function () {
|
|
|
|
return this.$store.getters.getFavorites
|
|
|
|
},
|
|
|
|
|
|
|
|
inFavoritesPlaylist: function () {
|
|
|
|
const index = this.favoritesPlaylist.videos.findIndex((video) => {
|
|
|
|
return video.videoId === this.id
|
|
|
|
})
|
|
|
|
|
|
|
|
return index !== -1
|
|
|
|
},
|
|
|
|
|
|
|
|
favoriteIconTheme: function () {
|
|
|
|
return this.inFavoritesPlaylist ? 'base favorite' : 'base'
|
|
|
|
},
|
|
|
|
|
2020-10-08 21:01:46 +02:00
|
|
|
downloadLinkNames: function () {
|
|
|
|
return this.downloadLinks.map((download) => {
|
|
|
|
return download.label
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
downloadLinkValues: function () {
|
|
|
|
return this.downloadLinks.map((download) => {
|
|
|
|
return download.url
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
2020-08-07 02:20:42 +02:00
|
|
|
formatTypeNames: function () {
|
|
|
|
return [
|
|
|
|
this.$t('Change Format.Use Dash Formats').toUpperCase(),
|
|
|
|
this.$t('Change Format.Use Legacy Formats').toUpperCase(),
|
|
|
|
this.$t('Change Format.Use Audio Formats').toUpperCase()
|
|
|
|
]
|
|
|
|
},
|
|
|
|
|
2020-02-16 19:30:00 +01:00
|
|
|
totalLikeCount: function () {
|
|
|
|
return this.likeCount + this.dislikeCount
|
|
|
|
},
|
|
|
|
|
2021-10-06 23:09:08 +02:00
|
|
|
parsedLikeCount: function () {
|
|
|
|
if (this.hideVideoLikesAndDislikes) {
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
|
|
|
|
const locale = this.currentLocale.replace('_', '-')
|
|
|
|
return this.likeCount.toLocaleString([locale, 'en'])
|
|
|
|
},
|
|
|
|
|
|
|
|
parsedDislikeCount: function () {
|
|
|
|
if (this.hideVideoLikesAndDislikes) {
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
|
|
|
|
const locale = this.currentLocale.replace('_', '-')
|
|
|
|
return this.dislikeCount.toLocaleString([locale, 'en'])
|
|
|
|
},
|
|
|
|
|
2020-02-16 19:30:00 +01:00
|
|
|
likePercentageRatio: function () {
|
|
|
|
return parseInt(this.likeCount / this.totalLikeCount * 100)
|
|
|
|
},
|
|
|
|
|
|
|
|
parsedViewCount: function () {
|
2020-10-06 04:27:32 +02:00
|
|
|
if (this.hideVideoViews) {
|
|
|
|
return null
|
|
|
|
}
|
2020-08-07 02:20:42 +02:00
|
|
|
return this.viewCount.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',') + ` ${this.$t('Video.Views').toLowerCase()}`
|
2020-02-16 19:30:00 +01:00
|
|
|
},
|
|
|
|
|
2020-08-31 23:35:22 +02:00
|
|
|
isSubscribed: function () {
|
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 19:42:24 +01:00
|
|
|
const subIndex = this.activeProfile.subscriptions.findIndex((channel) => {
|
2020-08-31 23:35:22 +02:00
|
|
|
return channel.id === this.channelId
|
|
|
|
})
|
|
|
|
|
|
|
|
if (subIndex === -1) {
|
|
|
|
return false
|
|
|
|
} else {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-02-16 19:30:00 +01:00
|
|
|
subscribedText: function () {
|
2020-08-31 23:35:22 +02:00
|
|
|
if (this.isSubscribed) {
|
|
|
|
return `${this.$t('Channel.Unsubscribe').toUpperCase()} ${this.subscriptionCountText}`
|
|
|
|
} else {
|
|
|
|
return `${this.$t('Channel.Subscribe').toUpperCase()} ${this.subscriptionCountText}`
|
|
|
|
}
|
2020-06-19 15:43:08 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
dateString() {
|
|
|
|
const date = new Date(this.published)
|
2021-10-02 17:43:42 +02:00
|
|
|
const locale = this.currentLocale.replace('_', '-')
|
|
|
|
const localeDateString = new Intl.DateTimeFormat([locale, 'en'], { dateStyle: 'medium' }).format(date)
|
|
|
|
return `${localeDateString}`
|
2020-10-31 15:57:51 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
publishedString() {
|
|
|
|
if (this.isLiveContent && this.isLive) {
|
|
|
|
return this.$t('Video.Started streaming on')
|
|
|
|
} else if (this.isLiveContent && !this.isLive) {
|
|
|
|
return this.$t('Video.Streamed on')
|
|
|
|
} else {
|
|
|
|
return this.$t('Video.Published on')
|
|
|
|
}
|
2021-06-13 17:31:43 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
externalPlayer: function () {
|
|
|
|
return this.$store.getters.getExternalPlayer
|
|
|
|
},
|
|
|
|
|
|
|
|
defaultPlayback: function () {
|
|
|
|
return this.$store.getters.getDefaultPlayback
|
2020-02-16 19:30:00 +01:00
|
|
|
}
|
|
|
|
},
|
2021-02-22 04:07:50 +01:00
|
|
|
mounted: function () {
|
2021-02-27 21:15:06 +01:00
|
|
|
if ('mediaSession' in navigator) {
|
|
|
|
/* eslint-disable-next-line */
|
|
|
|
navigator.mediaSession.metadata = new MediaMetadata({
|
|
|
|
title: this.title,
|
|
|
|
artist: this.channelName,
|
|
|
|
artwork: [
|
|
|
|
{
|
|
|
|
src: this.videoThumbnail,
|
|
|
|
sizes: '128x128',
|
|
|
|
type: 'image/png'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
})
|
|
|
|
}
|
2021-02-22 04:07:50 +01:00
|
|
|
},
|
2020-02-16 19:30:00 +01:00
|
|
|
methods: {
|
2021-06-13 17:31:43 +02:00
|
|
|
handleExternalPlayer: function () {
|
|
|
|
this.$emit('pause-player')
|
|
|
|
|
|
|
|
this.openInExternalPlayer({
|
|
|
|
strings: this.$t('Video.External Player'),
|
|
|
|
watchProgress: this.getTimestamp(),
|
|
|
|
playbackRate: this.defaultPlayback,
|
|
|
|
videoId: this.id,
|
|
|
|
playlistId: this.playlistId,
|
|
|
|
playlistIndex: this.getPlaylistIndex(),
|
|
|
|
playlistReverse: this.getPlaylistReverse(),
|
|
|
|
playlistShuffle: this.getPlaylistShuffle(),
|
|
|
|
playlistLoop: this.getPlaylistLoop()
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
2020-02-16 19:30:00 +01:00
|
|
|
goToChannel: function () {
|
2020-05-17 22:12:58 +02:00
|
|
|
this.$router.push({ path: `/channel/${this.channelId}` })
|
2020-02-16 19:30:00 +01:00
|
|
|
},
|
|
|
|
|
2021-01-15 00:03:23 +01:00
|
|
|
toggleSave: function () {
|
|
|
|
if (this.inFavoritesPlaylist) {
|
|
|
|
this.removeFromPlaylist()
|
|
|
|
} else {
|
|
|
|
this.addToPlaylist()
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-02-16 19:30:00 +01:00
|
|
|
handleSubscription: function () {
|
2020-12-02 19:36:08 +01:00
|
|
|
if (this.channelId === '') {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
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 19:42:24 +01:00
|
|
|
const currentProfile = JSON.parse(JSON.stringify(this.activeProfile))
|
2020-08-31 23:35:22 +02:00
|
|
|
const primaryProfile = JSON.parse(JSON.stringify(this.profileList[0]))
|
|
|
|
|
|
|
|
if (this.isSubscribed) {
|
|
|
|
currentProfile.subscriptions = currentProfile.subscriptions.filter((channel) => {
|
|
|
|
return channel.id !== this.channelId
|
|
|
|
})
|
|
|
|
|
|
|
|
this.updateProfile(currentProfile)
|
|
|
|
this.showToast({
|
2020-09-16 14:51:24 +02:00
|
|
|
message: this.$t('Channel.Channel has been removed from your subscriptions')
|
2020-08-31 23:35:22 +02:00
|
|
|
})
|
|
|
|
|
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 19:42:24 +01:00
|
|
|
if (this.activeProfile._id === MAIN_PROFILE_ID) {
|
2020-08-31 23:35:22 +02:00
|
|
|
// Check if a subscription exists in a different profile.
|
|
|
|
// Remove from there as well.
|
|
|
|
let duplicateSubscriptions = 0
|
|
|
|
|
|
|
|
this.profileList.forEach((profile) => {
|
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 19:42:24 +01:00
|
|
|
if (profile._id === MAIN_PROFILE_ID) {
|
2020-08-31 23:35:22 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
const parsedProfile = JSON.parse(JSON.stringify(profile))
|
|
|
|
const index = parsedProfile.subscriptions.findIndex((channel) => {
|
|
|
|
return channel.id === this.channelId
|
|
|
|
})
|
|
|
|
|
|
|
|
if (index !== -1) {
|
|
|
|
duplicateSubscriptions++
|
|
|
|
|
|
|
|
parsedProfile.subscriptions = parsedProfile.subscriptions.filter((x) => {
|
|
|
|
return x.id !== this.channelId
|
|
|
|
})
|
|
|
|
|
|
|
|
this.updateProfile(parsedProfile)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
if (duplicateSubscriptions > 0) {
|
2020-09-16 14:51:24 +02:00
|
|
|
const message = this.$t('Channel.Removed subscription from $ other channel(s)')
|
2020-08-31 23:35:22 +02:00
|
|
|
this.showToast({
|
2020-09-16 14:51:24 +02:00
|
|
|
message: message.replace('$', duplicateSubscriptions)
|
2020-08-31 23:35:22 +02:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
const subscription = {
|
|
|
|
id: this.channelId,
|
|
|
|
name: this.channelName,
|
|
|
|
thumbnail: this.channelThumbnail
|
|
|
|
}
|
|
|
|
currentProfile.subscriptions.push(subscription)
|
|
|
|
|
|
|
|
this.updateProfile(currentProfile)
|
|
|
|
this.showToast({
|
2020-09-16 14:51:24 +02:00
|
|
|
message: this.$t('Channel.Added channel to your subscriptions')
|
2020-08-31 23:35:22 +02:00
|
|
|
})
|
|
|
|
|
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 19:42:24 +01:00
|
|
|
if (this.activeProfile._id !== MAIN_PROFILE_ID) {
|
2020-08-31 23:35:22 +02:00
|
|
|
const index = primaryProfile.subscriptions.findIndex((channel) => {
|
|
|
|
return channel.id === this.channelId
|
|
|
|
})
|
|
|
|
|
|
|
|
if (index === -1) {
|
|
|
|
primaryProfile.subscriptions.push(subscription)
|
|
|
|
this.updateProfile(primaryProfile)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-02-16 19:30:00 +01:00
|
|
|
},
|
|
|
|
|
2020-02-19 04:31:10 +01:00
|
|
|
handleFormatChange: function (format) {
|
|
|
|
switch (format) {
|
|
|
|
case 'dash':
|
|
|
|
this.$parent.enableDashFormat()
|
|
|
|
break
|
|
|
|
case 'legacy':
|
|
|
|
this.$parent.enableLegacyFormat()
|
|
|
|
break
|
2020-06-01 04:47:22 +02:00
|
|
|
case 'audio':
|
|
|
|
this.$parent.enableAudioFormat()
|
|
|
|
break
|
2020-02-19 04:31:10 +01:00
|
|
|
}
|
2020-08-05 05:44:34 +02:00
|
|
|
},
|
|
|
|
|
2021-01-15 00:03:23 +01:00
|
|
|
addToPlaylist: function () {
|
|
|
|
const videoData = {
|
|
|
|
videoId: this.id,
|
|
|
|
title: this.title,
|
|
|
|
author: this.channelName,
|
|
|
|
authorId: this.channelId,
|
|
|
|
published: '',
|
|
|
|
description: this.description,
|
|
|
|
viewCount: this.viewCount,
|
|
|
|
lengthSeconds: this.lengthSeconds,
|
|
|
|
timeAdded: new Date().getTime(),
|
|
|
|
isLive: false,
|
|
|
|
paid: false,
|
|
|
|
type: 'video'
|
|
|
|
}
|
|
|
|
|
|
|
|
const payload = {
|
|
|
|
playlistName: 'Favorites',
|
|
|
|
videoData: videoData
|
|
|
|
}
|
|
|
|
|
|
|
|
this.addVideo(payload)
|
|
|
|
|
|
|
|
this.showToast({
|
2021-01-15 04:37:52 +01:00
|
|
|
message: this.$t('Video.Video has been saved')
|
2021-01-15 00:03:23 +01:00
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
removeFromPlaylist: function () {
|
|
|
|
const payload = {
|
|
|
|
playlistName: 'Favorites',
|
|
|
|
videoId: this.id
|
|
|
|
}
|
|
|
|
|
|
|
|
this.removeVideo(payload)
|
2021-01-15 04:37:52 +01:00
|
|
|
|
|
|
|
this.showToast({
|
|
|
|
message: this.$t('Video.Video has been removed from your saved list')
|
|
|
|
})
|
2021-01-15 00:03:23 +01:00
|
|
|
},
|
|
|
|
|
2020-08-05 05:44:34 +02:00
|
|
|
...mapActions([
|
2020-08-31 23:35:22 +02:00
|
|
|
'showToast',
|
2021-06-13 17:31:43 +02:00
|
|
|
'openInExternalPlayer',
|
2021-01-15 00:03:23 +01:00
|
|
|
'updateProfile',
|
|
|
|
'addVideo',
|
2021-05-22 01:49:48 +02:00
|
|
|
'removeVideo',
|
|
|
|
'openExternalLink'
|
2020-08-05 05:44:34 +02:00
|
|
|
])
|
2020-02-16 19:30:00 +01:00
|
|
|
}
|
|
|
|
})
|