FreeTube/src/renderer/store/modules/settings.js

639 lines
19 KiB
JavaScript
Raw Normal View History

import i18n, { loadLocale } from '../../i18n/index'
import allLocales from '../../../../static/locales/activeLocales.json'
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, IpcChannels, SyncEvents } from '../../../constants'
import { DBSettingHandlers } from '../../../datastores/handlers/index'
import { getSystemLocale, showToast } from '../../helpers/utils'
2020-02-16 19:30:00 +01:00
/*
* Due to the complexity of the settings module in FreeTube, a more
* in-depth explanation for adding new settings is required.
*
* The explanation will be written with the assumption that
* the reader knows how Vuex works.
*
* And no, there's no need to read the entire wall of text.
* We'll direct you where you need to go as we walk you through it.
* Additionally, the text actually looks bigger than it truly is.
* Each line has, at most, 72 characters.
*
****
* Introduction
*
* You can add a new setting in three different methods.
*
* The first two methods benefit from the auto-generation of
* a getter, a mutation and a few actions related to the setting.
* Those two methods should be preferred whenever possible:
* - `state`
* - `stateWithSideEffects`
*
* The last one DOES NOT feature any kind of auto-generation and should
* only be used in scenarios that don't fall under the other 2 options:
* - `customState`
*
****
* ASIDE:
* The aforementioned "side effects" cover a large area
* of interactions with other modules
* A good example would be a setting that utilizes the Electron API
* when its value changes.
*
****
* First and foremost, you have to understand what type of setting
* you intend to add to the app.
*
* You'll have to select one of these three scenarios:
*
* 1) You just want to add a simple setting that does not actively
* interact with the Electron API, `localStorage` or
* other parts outside of the settings module.
* -> Please consult the `state` section.
*
* 2) You want to add a more complex setting that interacts
* with other parts of the app and tech stack.
* -> Please consult the `state` and `stateWithSideEffects` sections.
*
* 3) You want to add a completely custom state based setting
* that does not work like the usual settings.
* -> Please consult the `state` and `customState` sections.
*
****
* `state`
* This object contains settings that have NO SIDE EFFECTS.
*
* A getter, mutation and an action function is auto-generated
* for every setting present in the `state` object.
* They have the following format (exemplified with setting 'example'):
*
* Getter: `getExample` (gets the value from current state)
* Mutation:
* `setExample`
* (takes a value
* and uses it to update the current state)
* Action:
* `updateExample`
* (takes a value,
* saves it to the database
* and calls `setExample` with it)
*
***
* `stateWithSideEffects`
* This object contains settings that have SIDE EFFECTS.
*
* Each one of these settings must specify an object
* with the following properties:
* - `defaultValue`
* (which is the value you would put down if
* you were to add the setting to the regular `state` object)
*
* - `sideEffectsHandler`
* (which should essentially be a callback of type
* `(store, value) => void`
* that deals with the side effects for that setting)
*
* NOTE: Example implementations of such settings can be found
* in the `stateWithSideEffects` object in case
* the explanation isn't clear enough.
*
* All functions auto-generated for settings in `state`
* (if you haven't read the `state` section, do it now),
* are also auto-generated for settings in `stateWithSideEffects`,
* with a few key differences (exemplified with setting 'example'):
*
* - an additional action is auto-generated:
* - `triggerExampleSideEffects`
* (triggers the `sideEffectsHandler` for that setting;
* you'll most likely never call this directly)
*
* - the behavior of `updateExample` changes a bit:
* - `updateExample`
* (saves value to the database,
* calls `triggerExampleSideEffects` and calls `setExample`)
*
***
* `customState`
* This object contains settings that
* don't linearly fall under the other two options.
*
* No auto-generation of any kind is performed
* when a setting is added to `customState`
*
* You must manually add any getters, mutations and actions to
* `customGetters`, `customMutations` and `customActions` respectively
* that you find appropriate for that setting.
*
* NOTE:
* When adding a setting to the `customState`,
* additional consultation with the FreeTube team is preferred
* to evaluate if it is truly necessary
* and to ensure that the implementation works as intended.
*
* A good example of a setting of this type would be `usingElectron`.
* This setting doesn't need to be persisted in the database
* and it doesn't change over time.
* Therefore, it needs a getter (which we add to `customGetters`), but
* has no need for a mutation or any sort of action.
*
****
* ENDING NOTES
*
* Only two more things that need mentioning.
*
* 1) It's perfectly fine to add extra functionality
* to the `customGetters`, `customMutations` and `customActions`,
* whether it's related to a setting or just serving as
* standalone functionality for the module
* (e.g. `grabUserSettings` (standalone action))
*
* 2) It's also possible to OVERRIDE auto-generated functionality by
* adding functions with the same identifier to
* the respective `custom__` object,
* but you must have an acceptable reason for doing so.
****
*/
// HELPERS
const capitalize = str => str.replace(/^\w/, c => c.toUpperCase())
const defaultGetterId = settingId => 'get' + capitalize(settingId)
const defaultMutationId = settingId => 'set' + capitalize(settingId)
const defaultUpdaterId = settingId => 'update' + capitalize(settingId)
const defaultSideEffectsTriggerId = settingId =>
'trigger' + capitalize(settingId) + 'SideEffects'
/*****/
2020-02-16 19:30:00 +01:00
const state = {
allSettingsSectionsExpandedByDefault: false,
autoplayPlaylists: true,
autoplayVideos: true,
backendFallback: process.env.SUPPORTS_LOCAL_API,
backendPreference: !process.env.SUPPORTS_LOCAL_API ? 'invidious' : 'local',
barColor: false,
checkForBlogPosts: true,
checkForUpdates: true,
baseTheme: 'system',
mainColor: 'Red',
secColor: 'Blue',
defaultCaptionSettings: '{}',
defaultInterval: 5,
defaultPlayback: 1,
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
defaultProfile: MAIN_PROFILE_ID,
defaultQuality: '720',
defaultSkipInterval: 5,
defaultTheatreMode: false,
defaultVideoFormat: 'dash',
disableSmoothScrolling: false,
displayVideoPlayButton: true,
enableSearchSuggestions: true,
enableSubtitlesByDefault: false,
enterFullscreenOnDisplayRotate: false,
externalLinkHandling: '',
Add support for External Players (closes #418) (#1271) * feat: add support for opening videos/playlists in external players (like mpv) #418 Signed-off-by: Randshot <randshot@norealm.xyz> * feat: move external player settings into own section feat: add warnings for when the external player doesn't support the current action (e.g. reversing playlists) feat: add toggle in settings for ignoring unsupported action warnings Signed-off-by: Randshot <randshot@norealm.xyz> * improvement: do not append start offset argument when the watch progress is 0 Signed-off-by: Randshot <randshot@norealm.xyz> * fix: fix undefined showToast error when clicking on the external player playlist button Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add icon button for external player to watch-video-info (below video player) component improvement: refactor the code for opening the external player into a separate function in utils.js Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add support for ytdl protocol urls (supportsYtdlProtocol) chore: fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add support for passing default playback rate to external player improvement: add warning message for when the external player does not support starting playback at a given offset chore: rename reverse, shuffle, and loopPlaylist fields for consistency Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add setting for custom external player command line arguments Signed-off-by: Randshot <randshot@norealm.xyz> * chore: fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * improvement(watch-video-info.js): change the default for playlistId back to null (consistent with other occurrences) improvement(utils.js/openInExternalPlayer): also check for empty playlistId string fix(watch-video-info.js): fix merge error Signed-off-by: Randshot <randshot@norealm.xyz> * improvement(components/ft-list-video): check whether watch history is turned on, before adding a video to it fix(store/utils): fix playlistReverse typo, causing `undefined` being set as a command line argument fix(store/utils): check for 'string' type, instead of `null` and `undefined` fix(views/Watch): fix getPlaylistIndex returning an incorrect index, when reverse was turned on chore(locales/en-US): fix thumbnail and suppress typo chore(locales/en_GB): fix thumbnail and suppress typo Signed-off-by: Randshot <randshot@norealm.xyz> * feat: pause player when opening video in external player Signed-off-by: Randshot <randshot@norealm.xyz> * feat(externalPlayer): refactor externalPlayerCmdArguments into a separate static file `static/external-player-map.json` chore(components/ft-list-video): fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * Revert "feat: pause player when opening video in external player" This reverts commit 28b4713334bf941be9e403abf517bb4b89beb04f. * feat: pause the app's player when opening video in external player * This commit addresses above requested changes. improvement(components/external-player-settings): move `externalPlayer` check to `ft-flex-box` improvement(components/external-player-settings): use `update*` methods, instead of `handle*` improvement(store/utils): move child_process invocation to `main/index.js` via IPC call to renderer improvement(store/utils): use `dispatch` for calling actions improvement(store/utils): get external player related settings directly in the action improvement(renderer/App): move `checkExternalPlayer` call down into `usingElectron` if statement fix(renderer/App): fix lint error improvement(components/ft-list-playlist): remove unnecessary payload fields fix(components/ft-list-playlist): fix typo in component name improvement(components/ft-list-video): remove unnecessary payload fields improvement(components/watch-video-info): remove unnecessary payload fields improvement(views/Settings): add `usingElectron` condition Signed-off-by: Randshot <randshot@norealm.xyz> * fix(store/utils): fix toast message error Signed-off-by: Randshot <randshot@norealm.xyz> * fix(store/utils): fix a few code mess-ups Co-authored-by: Svallinn <41585298+Svallinn@users.noreply.github.com>
2021-06-13 17:31:43 +02:00
externalPlayer: '',
externalPlayerExecutable: '',
externalPlayerIgnoreWarnings: false,
externalPlayerIgnoreDefaultArgs: false,
Add support for External Players (closes #418) (#1271) * feat: add support for opening videos/playlists in external players (like mpv) #418 Signed-off-by: Randshot <randshot@norealm.xyz> * feat: move external player settings into own section feat: add warnings for when the external player doesn't support the current action (e.g. reversing playlists) feat: add toggle in settings for ignoring unsupported action warnings Signed-off-by: Randshot <randshot@norealm.xyz> * improvement: do not append start offset argument when the watch progress is 0 Signed-off-by: Randshot <randshot@norealm.xyz> * fix: fix undefined showToast error when clicking on the external player playlist button Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add icon button for external player to watch-video-info (below video player) component improvement: refactor the code for opening the external player into a separate function in utils.js Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add support for ytdl protocol urls (supportsYtdlProtocol) chore: fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add support for passing default playback rate to external player improvement: add warning message for when the external player does not support starting playback at a given offset chore: rename reverse, shuffle, and loopPlaylist fields for consistency Signed-off-by: Randshot <randshot@norealm.xyz> * feat: add setting for custom external player command line arguments Signed-off-by: Randshot <randshot@norealm.xyz> * chore: fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * improvement(watch-video-info.js): change the default for playlistId back to null (consistent with other occurrences) improvement(utils.js/openInExternalPlayer): also check for empty playlistId string fix(watch-video-info.js): fix merge error Signed-off-by: Randshot <randshot@norealm.xyz> * improvement(components/ft-list-video): check whether watch history is turned on, before adding a video to it fix(store/utils): fix playlistReverse typo, causing `undefined` being set as a command line argument fix(store/utils): check for 'string' type, instead of `null` and `undefined` fix(views/Watch): fix getPlaylistIndex returning an incorrect index, when reverse was turned on chore(locales/en-US): fix thumbnail and suppress typo chore(locales/en_GB): fix thumbnail and suppress typo Signed-off-by: Randshot <randshot@norealm.xyz> * feat: pause player when opening video in external player Signed-off-by: Randshot <randshot@norealm.xyz> * feat(externalPlayer): refactor externalPlayerCmdArguments into a separate static file `static/external-player-map.json` chore(components/ft-list-video): fix lint error Signed-off-by: Randshot <randshot@norealm.xyz> * Revert "feat: pause player when opening video in external player" This reverts commit 28b4713334bf941be9e403abf517bb4b89beb04f. * feat: pause the app's player when opening video in external player * This commit addresses above requested changes. improvement(components/external-player-settings): move `externalPlayer` check to `ft-flex-box` improvement(components/external-player-settings): use `update*` methods, instead of `handle*` improvement(store/utils): move child_process invocation to `main/index.js` via IPC call to renderer improvement(store/utils): use `dispatch` for calling actions improvement(store/utils): get external player related settings directly in the action improvement(renderer/App): move `checkExternalPlayer` call down into `usingElectron` if statement fix(renderer/App): fix lint error improvement(components/ft-list-playlist): remove unnecessary payload fields fix(components/ft-list-playlist): fix typo in component name improvement(components/ft-list-video): remove unnecessary payload fields improvement(components/watch-video-info): remove unnecessary payload fields improvement(views/Settings): add `usingElectron` condition Signed-off-by: Randshot <randshot@norealm.xyz> * fix(store/utils): fix toast message error Signed-off-by: Randshot <randshot@norealm.xyz> * fix(store/utils): fix a few code mess-ups Co-authored-by: Svallinn <41585298+Svallinn@users.noreply.github.com>
2021-06-13 17:31:43 +02:00
externalPlayerCustomArgs: '',
expandSideBar: false,
forceLocalBackendForLegacy: false,
hideActiveSubscriptions: false,
hideChannelCommunity: false,
hideChannelPlaylists: false,
hideChannelReleases: false,
hideChannelPodcasts: false,
hideChannelShorts: false,
hideChannelSubscriptions: false,
hideCommentLikes: false,
hideCommentPhotos: false,
hideComments: false,
hideFeaturedChannels: false,
channelsHidden: '[]',
forbiddenTitles: '[]',
hideVideoDescription: false,
hideLiveChat: false,
hideLiveStreams: false,
hideHeaderLogo: false,
hidePlaylists: false,
hidePopularVideos: false,
hideRecommendedVideos: false,
hideSearchBar: false,
hideSharingActions: false,
hideSubscriptionsVideos: false,
hideSubscriptionsShorts: false,
hideSubscriptionsLive: false,
hideSubscriptionsCommunity: false,
hideTrendingVideos: false,
hideUnsubscribeButton: false,
hideUpcomingPremieres: false,
hideVideoLikesAndDislikes: false,
hideVideoViews: false,
hideWatchedSubs: false,
hideLabelsSideBar: false,
hideChapters: false,
showDistractionFreeTitles: false,
landingPage: 'subscriptions',
listType: 'grid',
maxVideoPlaybackRate: 3,
onlyShowLatestFromChannel: false,
playNextVideo: false,
proxyHostname: '127.0.0.1',
proxyPort: '9050',
proxyProtocol: 'socks5',
proxyVideos: !process.env.SUPPORTS_LOCAL_API,
region: 'US',
rememberHistory: true,
saveWatchedProgress: true,
saveVideoHistoryWithLastViewedPlaylist: true,
showFamilyFriendlyOnly: false,
sponsorBlockShowSkippedToast: true,
sponsorBlockUrl: 'https://sponsor.ajay.app',
sponsorBlockSponsor: {
color: 'Blue',
skip: 'autoSkip'
},
sponsorBlockSelfPromo: {
color: 'Yellow',
skip: 'showInSeekBar'
},
sponsorBlockInteraction: {
color: 'Green',
skip: 'showInSeekBar'
},
sponsorBlockIntro: {
color: 'Orange',
skip: 'doNothing'
},
sponsorBlockOutro: {
color: 'Orange',
skip: 'doNothing'
},
sponsorBlockRecap: {
color: 'Orange',
skip: 'doNothing'
},
sponsorBlockMusicOffTopic: {
color: 'Orange',
skip: 'doNothing'
},
sponsorBlockFiller: {
color: 'Orange',
skip: 'doNothing'
},
thumbnailPreference: '',
blurThumbnails: false,
useProxy: false,
userPlaylistSortOrder: 'date_added_descending',
useRssFeeds: false,
useSponsorBlock: false,
videoVolumeMouseScroll: false,
In app download (#1971) * src/renderer/store/modules/utils.js, src/renderer/components/watch-video-info/watch-video-info.vue, src/renderer/components/watch-video-info/watch-video-info.js, src/renderer/components/ft-icon-button/ft-icon-button.js, src/main/index.js in-app download in hardcoded path * download into variable folder supported download can be done into a specify folder defined in the settings or can be done by choosing a folder just before the downloading * src/renderer/store/modules/utils.js: folder is asked before downloading when appropriate * src/renderer/store/modules/utils.js: toast added for success and faillure * src/renderer/store/modules/utils.js: mecanism to show download progress * src/renderer/store/modules/utils.js: percentage symbol added to toast message when displaying progress * src/renderer/components/download-settings/download-settings.js: clarification comment about electron * src/renderer/store/modules/utils.js: typo in comment resolved * src/renderer/store/modules/utils.js: show a toast when there is a file error * static/locales/fr-FR.yaml: resolved typo in Choose Path * src/renderer/store/modules/utils.js: download progress notification toast deleted * corrections of typos, changes in toast messages, toast messages translatable by modifying the ft-toast component to allow translatable strings * cleaner code for translatable toast * downloadMedia argument changed from array to object * src/renderer/components/download-settings/download-settings.sass: trailling space added * Apply suggestions from code review folder changed for folderPath Co-authored-by: PikachuEXE <pikachuexe@gmail.com> * fix forgotten folderPath renaming * extra space deleted * starting toast displayed after download folder asks * audio button deleted * experimental electron web library deleted because can cause performance issues * placeholder for web support * made better condition for web and electon compatibility and small variable renaming * better error message when user cancel the download * falling back to asking the user if the download repository doesn't exist * falling back mode implemented * console.log for debugging deleted * useless import deleted * small renaming Co-authored-by: PikachuEXE <pikachuexe@gmail.com>
2022-01-30 18:49:16 +01:00
videoPlaybackRateMouseScroll: false,
videoSkipMouseScroll: false,
videoPlaybackRateInterval: 0.25,
downloadAskPath: true,
downloadFolderPath: '',
downloadBehavior: 'open',
enableScreenshot: false,
screenshotFormat: 'png',
screenshotQuality: 95,
screenshotAskPath: false,
screenshotFolderPath: '',
screenshotFilenamePattern: '%Y%M%D-%H%N%S',
fetchSubscriptionsAutomatically: true,
settingsPassword: '',
allowDashAv1Formats: false,
useDeArrowTitles: false,
useDeArrowThumbnails: false,
deArrowThumbnailGeneratorUrl: 'https://dearrow-thumb.ajay.app',
// This makes the `favorites` playlist uses as quick bookmark target
// If the playlist is removed quick bookmark is disabled
quickBookmarkTargetPlaylistId: 'favorites',
generalAutoLoadMorePaginatedItemsEnabled: false,
2020-02-16 19:30:00 +01:00
}
const stateWithSideEffects = {
currentLocale: {
defaultValue: 'en-US',
sideEffectsHandler: async function ({ dispatch }, value) {
const defaultLocale = 'en-US'
let targetLocale = value
if (value === 'system') {
const systemLocaleName = (await getSystemLocale()).replace('-', '_') // ex: en_US
const systemLocaleSplit = systemLocaleName.split('_') // ex: en
const targetLocaleOptions = allLocales.filter((locale) => {
// filter out other languages
const localeLang = locale.replace('-', '_').split('_')[0]
return localeLang.includes(systemLocaleSplit[0])
}).sort((a, b) => {
const aLocaleName = a.replace('-', '_')
const bLocaleName = b.replace('-', '_')
const aLocale = aLocaleName.split('_') // ex: [en, US]
const bLocale = bLocaleName.split('_')
if (aLocaleName === systemLocaleName) { // country & language match, prefer a
return -1
} else if (bLocaleName === systemLocaleName) { // country & language match, prefer b
return 1
} else if (aLocale.length === 1) { // no country code for a, prefer a
return -1
} else if (bLocale.length === 1) { // no country code for b, prefer b
return 1
} else { // a & b have different country code from system, sort alphabetically
return aLocaleName.localeCompare(bLocaleName)
}
})
if (targetLocaleOptions.length > 0) {
targetLocale = targetLocaleOptions[0]
} else {
// Go back to default value if locale is unavailable
targetLocale = defaultLocale
// Translating this string isn't necessary
// because the user will always see it in the default locale
// (in this case, English (US))
2022-10-14 07:59:49 +02:00
showToast(`Locale not found, defaulting to ${defaultLocale}`)
}
}
const loadPromises = []
if (targetLocale !== defaultLocale) {
// "en-US" is used as a fallback for missing strings in other locales
loadPromises.push(
loadLocale(defaultLocale)
)
}
// "es" is used as a fallback for "es_AR" and "es-MX"
if (targetLocale === 'es_AR' || targetLocale === 'es-MX') {
loadPromises.push(
loadLocale('es')
)
}
// "pt" is used as a fallback for "pt-PT" and "pt-BR"
if (targetLocale === 'pt-PT' || targetLocale === 'pt-BR') {
loadPromises.push(
loadLocale('pt')
)
}
loadPromises.push(
loadLocale(targetLocale)
)
await Promise.allSettled(loadPromises)
i18n.locale = targetLocale
await dispatch('getRegionData', {
locale: targetLocale
})
}
},
defaultInvidiousInstance: {
defaultValue: '',
sideEffectsHandler: ({ commit, getters }, value) => {
if (value !== '' && getters.getCurrentInvidiousInstance !== value) {
commit('setCurrentInvidiousInstance', value)
}
}
},
defaultVolume: {
defaultValue: 1,
sideEffectsHandler: (_, value) => {
sessionStorage.setItem('volume', value)
value === 0 ? sessionStorage.setItem('muted', 'true') : sessionStorage.setItem('muted', 'false')
sessionStorage.setItem('defaultVolume', value)
}
},
uiScale: {
defaultValue: 100,
sideEffectsHandler: (_, value) => {
if (process.env.IS_ELECTRON) {
const { webFrame } = require('electron')
webFrame.setZoomFactor(value / 100)
}
}
}
}
const customState = {
}
const customGetters = {
}
const customMutations = {}
/**********/
/*
* DO NOT TOUCH THIS SECTION
* If you wanna add to custom data or logic to the module,
* do so in the aproppriate `custom_` variable
*
* Some of the custom actions below use these properties, so I'll be
* adding them here instead of further down for clarity's sake
*/
Object.assign(customState, {
settingsWithSideEffects: Object.keys(stateWithSideEffects)
})
Object.assign(customGetters, {
settingHasSideEffects: (state) => {
return (id) => state.settingsWithSideEffects.includes(id)
}
})
/**********/
2020-02-16 19:30:00 +01:00
const customActions = {
grabUserSettings: async ({ commit, dispatch, getters }) => {
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
try {
// Assigning default settings for settings that have side effects
const userSettings = Object.entries(Object.assign({},
Object.fromEntries(Object.entries(stateWithSideEffects).map(([_id, { defaultValue }]) => { return [_id, defaultValue] })),
Object.fromEntries((await DBSettingHandlers.find()).map(({ _id, value }) => { return [_id, value] })))
)
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
for (const setting of userSettings) {
const [_id, value] = setting
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 (getters.settingHasSideEffects(_id)) {
dispatch(defaultSideEffectsTriggerId(_id), value)
}
if (Object.keys(mutations).includes(defaultMutationId(_id))) {
commit(defaultMutationId(_id), value)
}
}
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
} catch (errMessage) {
console.error(errMessage)
}
},
// Should be a root action, but we'll tolerate
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
setupListenersToSyncWindows: ({ commit, dispatch, getters }) => {
if (process.env.IS_ELECTRON) {
const { ipcRenderer } = require('electron')
ipcRenderer.on(IpcChannels.SYNC_SETTINGS, (_, { event, data }) => {
switch (event) {
case SyncEvents.GENERAL.UPSERT:
if (getters.settingHasSideEffects(data._id)) {
dispatch(defaultSideEffectsTriggerId(data._id), data.value)
}
commit(defaultMutationId(data._id), data.value)
break
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
default:
console.error('settings: invalid sync event received')
}
})
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
ipcRenderer.on(IpcChannels.SYNC_HISTORY, (_, { event, data }) => {
switch (event) {
case SyncEvents.GENERAL.UPSERT:
commit('upsertToHistoryCache', data)
break
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
case SyncEvents.HISTORY.UPDATE_WATCH_PROGRESS:
commit('updateRecordWatchProgressInHistoryCache', data)
break
case SyncEvents.HISTORY.UPDATE_PLAYLIST:
commit('updateRecordLastViewedPlaylistIdInHistoryCache', data)
break
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
case SyncEvents.GENERAL.DELETE:
commit('removeFromHistoryCacheById', data)
break
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
case SyncEvents.GENERAL.DELETE_ALL:
commit('setHistoryCacheSorted', [])
commit('setHistoryCacheById', {})
break
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
default:
console.error('history: invalid sync event received')
}
})
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
ipcRenderer.on(IpcChannels.SYNC_PROFILES, (_, { event, data }) => {
switch (event) {
case SyncEvents.GENERAL.CREATE:
commit('addProfileToList', data)
break
case SyncEvents.GENERAL.UPSERT:
commit('upsertProfileToList', data)
break
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
case SyncEvents.GENERAL.DELETE:
commit('removeProfileFromList', data)
break
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
default:
console.error('profiles: invalid sync event received')
}
})
(Multiple) Local Playlist (instead of saving video in one hidden list) (#4234) * ! Fix add/removing videos from favourite list * ! Fix playlist type not passed into video list item component * ! Fix playlist data loading issue on new windows * ! Fix user playlist data parsing * * Ensure playlist view rerender on video additonal removal for displayed playlist * ! Fix icons & moving videos up/down in user playlist * * Don't show move up/down buttons when cannot be done * * Make user playlist view filtering function now works for filtering playlists * ! Fix style of prompt from any button within playlist-info component * $ Refactor a function to use early return style * * Disallow empty playlist name when saving in playlist edit mode * * Update add video to playlist prompt to have simple filtering like user playlist view * * Update playlist view to only show video reorder/remove buttons in edit mode With notice message * ! Fix playlist view for remote playlist unnecessary reload on save * ! Fix add to playlist prompt behaviour when some playlists are hidden due to filtering * $ Remove unused watch function arguments * * Update user playlist view create new playlist button position * * Update playlist view to add transitions to video reorder/removal * * Allow playlist with different case to be created * * Update visibility of user playlist related action components according to hide playlist settings Only those visible on video, remote playlist are updated * * Update video items to only show add to playlist buttons on hover * - Remove add to favorites button from video list item component * * Update watch-video-info component to add "add to playlist" button * * Update watch-video-info component to remove "add to favourite" button * * Ensure video thumbnail image displayed in 16/9 aspect ratio Mainly due to YT missing video thumbnail image got different aspect ratio 4/3 * * Update new buttons theme * * Put edit playlist button before copy button * * Move "remove video from playlist" button to most right * * Make video reorder & remove button visible on hover in user playlist view, regardless of "edit mode" * ! Fix video count parsing for user playlist * * Update user playlist to allow duplicate video entries (per video ID) * * Remove extra attributes assignment to video object except `timeAdded` Unintended change * * Update copy playlist button to like adding multiple videos to playlists * * Update copy playlist prompt to prefill title if create new playlist prompt shown * * Ensure all playlists have `playlistName` * $- Remove unused playlist property `removeOnWatched` * * Update read all playlist code to ensure existing "default" playlist properties (_id, protected) have same values as those in default Also fix issue discovered during testing * *- Remove unnecessary code line * * Update playlists from default playlists to be deletable * ! Fix duplicate `timeAdded` value for videos copied from user playlist * ! Fix playlist import (tested with db file exported from this branch) * * Update grid view to only display playlist title up to 255 chars Still can see full title in single playlist view * * Update add video to playlist prompt to only display playlist title up to 255 chars * * Update text of new playlist button to be same as new profile button * * Ignore many extra keys from playlist objectrs Also make data import check for object keys against required keys not key counts * * Disallow playlist import from changing internal playlist ID of existing playlists Existing playlists are matched by playlist name, not by internal playlist ID * * Ensure playlist name & description trimmed when saved * * Add missing change for importing playlist to ignore `protected` * $ Refactor code for "video object has all require keys" * ! Fix style of prompt from any button within playlist-info component again z-index war * * Update some empty message & button text * * Ensure playlist item action buttons are hidden during animations * ! Fix other prompt z-index * * Update `showAddToPlaylistPromptForManyVideos` to throw error when required keys missing from passed in video data * *- Remove unused video property `paid` from playlist related code * *- Remove unused video property `type` from playlist related code * ! Fix duplicate playlist displayed on playlist conversion * *- Remove unused video property `published` from playlist related code * * Don't require & generate property `timeAdded` when display a prompt * *- Remove unused video property `isLive` from playlist related code * ! Fix text * ! Revert code change for debugging only * ! Fix CSS for "Ensure playlist item action buttons are hidden during animations" * * Update add playlist button to be shown for live videos * + Add clear all playlists button * * Update add video to playlist prompt to swap "save" & "create playlist" button * ! Fix playlist view won't load after default playlist added due to lack of playlist * * Show toast message when no playlist selected after pressing save button * * Update add video to playlist prompt to show latest updated playlist first Easier for copying playlist with new playlist(s) * ! Fix watch page when visited via history after viewing the video from a deleted user playlist * ! Fix share buttons emitting user playlist IDs * * Add toast message after removing all playlists * ! Fix remote playlist video list rendering with duplicate videos * ! Fix missing key for some direct child elements under `transition-group` * ! Fix animation introduced to unnecessary elements * ! Prevent video link click during animation * ! Fix playlist creation/removal not reflected in other windows * * Ensure playlist visual selected state in sync with data in parent * * Update add video to playlist prompt to auto select playlists created after prompt shown once * * Update copy playlist button to show warning about not loaded videos when some not loaded yet For remote playlist Won't work for Invidious though (coz no way to load more) * * Update add video prompt to make it easier to access buttons via keyboard * * Make video reorder & remove button always visible in user playlist view * * Make plus button can be focused with tab Side effect is thumbnail link can be focused too (otherwise can't make plus button visible) * * Update add video to playlist prompt to focus on search input on shown * * Accept playlist optional property `createdAt` when importing * * Update playlist view to always show add to playlist button * $ Refactor `inUserPlaylist` Only playlist view would supply `playlistType` * * Improve accessibility for new prompts * * Make edit playlist inputs focused on entering edit mode * * Make most prompts focus back to last focused element on close * $ Use tabindex 0 for prompts Possible tabindex values unnecessary with elements programatically focused * * Update add video to playlist prompt to focus back to search input after new playlist created * * Update ft-list-video to focus back on thumbnail link element after add to playlist prompt closed * ! Fix unable to import duplicate video entries into an existing playlist * ! Fix create playlist prompt looks unclosed after playlist created when opened via add video to playlist prompt * ! Fix duplicate video entry ID when playlist with duplicate videoId entries copied to another playlist * ! Fix issues caused by last merge in e291cc8b41b2273a0d77c9f35ea760f0e0f7ac10 * $ Remove unused imports * ! Fix default playlists added when no playlist stored had no required attributes added on 1st run * ! Fix invalid prop type warning * * Use v-if instead of v-show * $ Just assign bool value instead of if-else * + Update playlists view to add sorting option * $- Remove unnecessary property assignments * ! Fix issues caused by "Remove unnecessary property assignments" * ! Fix issues caused by "Remove unnecessary property assignments" * * Ensure sort by time also fallbacks to playlist name sorting * ! Fix add/remove video does not update playlist last created time * ! Fix multi window playlist sync * * Show filtering input & sorting element when no. of playlist > 1 * * Update upcoming video to allow saving in playlist * ! Fix unable to visit previous video when playing first video in a playlist * * Update sorting options labels * ! Fix add to play prompt max width * ! Fix user playlist view incorrectly sorted playlists by latest updated first when filtered * * Update add to playlist prompt to add sort options * $ Remove unused classname * ! Ensure new playlist button focused after add to playlist prompt closed while thumbnail link unselectable * * Add playlists sort order for last played at, update it on play * ! Fix bug introduced by last merge * ! Fix thumbnail not respecting backend preference * ! Fix empty playlist thumbnail in single playlist view * * Make adding large no. of videos faster * $ Remove unused mapActions entries * $ Remove unused and unusable playlist code for inserting video IDs into a playlist * * Update single playlist view to only show `Remove watched videos` btn when there is any video * ! Fix prompt style issue caused by old branch changes * ! Fix removing video from local playlist remove all entries with same video ID * ! Fix adding video does not have uniqueID & timeAdded set Caused by previous add many video performance fix * ! Fix navigation in user playlist between entries of same video * * Reflect playlist updates on watch page playlist panel * $- Remove outdated incorrect prompt style fix * ! Fix add video to playlist prompt too high when there are too many playlists * ! Fix watch page play next/prev video in local playlist * ! Fix error in online playlist playing * * Keep partial playlist backward compatibility by restoring `type` in persisted playlist videos * ! Fix grid item for playlist to hide external player button for local playlist * * Make history rememeber uniqueId (local playlist video entry) when playing video with local playlist * ! Fix grid item for video in user playlist to hide external player button * ! Fix grid item for video in history with user playlist to hide external player button * ! Fix grid item for video in watch page playlist component with user playlist to hide external player button * * Update watch page to clear `uniqueID` from query when not playing local playlist * ! Fix watch page about user playlist detection on new window * * Reflect playlist updates on watch page playlist panel, even for currently playing video * ! Allow video with local playlist to be played in external player, but without playlist Also add missing fix for WatchVideoInfo * ! Fix external player handling for video in local playlist * ! Fix ft-video having different URLs in links * yarn run lint-style-fix * $ Rename uniqueId to playlistItemId * * Ensure local playlist ID won't conflict with remote playlist ID * - Remove import video while creating playlist related code * * Make text translatable * * Make sort option text translatable * ! Fix reverse condition * $ Just use ?. * Code review changes * Spaces * beforeDestroy * Remove unused methods * Remove infoData * filter > find * avoid importing `crypto` from NodeJS * Compress CSS ruleset * $ Remove useless prefix from key * Use template for element with v-if only * Make playlist selector look more selectable (cursor: pointer) * Translate toast messages and fix remove watched videos from playlist * ! Fix translation * - Remove unused methods * $ Remove workaround for issue which cannot be reproduced anymore * $ Remove remaining useless code following last commit removing workaround * you have no playlist > you have no playlists * CSS use var --horizontal-directionality-coefficient * * Update danger buttons color to primary (like clear search cache button) * ! Fix playlist icon container size * ! Fix sorting in add video to playlist prompt when filtered * $- Update ft-inputs to removed prop input-tabindex * ! Fix vue warning * + Add toggle to export playlist for older FT * * Update tooltip text * ! Fix vue warning * * Update text align * * Remove the extra surrounding spaces * Backtick > quote * - Remove useless prop * Fix tootip in lower width view * Update default filename * * Make tooltip auto-wrap * Revert "* Make tooltip auto-wrap" This reverts commit 7d932b936c7814349e50204a7979d2d0f5b0ea73. * Adjust tooltip styling * * Wait for local playlist loading only when playing with a user playlist * * Wait for local playlist loading only when playing with a user playlist requested Request user playlist can still be absent (but not requested for no playlist or remote playlist) * ! Fix single playlist view cover image having link when no video * ! Workaround create playlist prompt won't close when enter pressed in input box * ! Fix clear text button style * ! Fix copying playlist twice to the same user playlist produces same playlistItemId * ! Fix add video to playlist prompt input box style * ! Fix workaround for "create playlist prompt won't close when enter pressed in input box" * ! Ensure add video to playlist prompt updated when a playlist deleted (in another window) * ! Avoid saving and displaying unwanted video attributes into playlists * ! Fix playlist view for deleted user playlists * ! Fix copying playlist twice to the same user playlist produces same playlistItemId Real fix Cause of issue: updating property of input objects (which is shared across multiple run) * ! Fix search suggestions being blocked by playlist info component in single playlist view * ! Fix warning when reversing playlist in watch view * ! Fix prompt in playlist view (playlistinfo component) not above sidebar * Remove CSS top comments absent in other CSS files * Remove not useful comment for CSS * Float with variable Co-authored-by: Jason <84899178+jasonhenriquez@users.noreply.github.com> * Revert "! Fix clear text button style" This reverts commit 44ed286848e3cdf4c52f29a867fe09964adffd78. * Missing change for Revert "! Fix clear text button style" * $ Remove unused style for ft-playlist-selector * Apply changes from review * * Use $tc for translation entries with different value according to count values * ! Fix playlist link in watch view --------- Co-authored-by: Jason Henriquez <jasonhenriquez@protonmail.com> Co-authored-by: Jason <84899178+jasonhenriquez@users.noreply.github.com>
2024-01-03 19:44:57 +01:00
ipcRenderer.on(IpcChannels.SYNC_PLAYLISTS, (_, { event, data }) => {
switch (event) {
case SyncEvents.GENERAL.CREATE:
commit('addPlaylists', data)
break
(Multiple) Local Playlist (instead of saving video in one hidden list) (#4234) * ! Fix add/removing videos from favourite list * ! Fix playlist type not passed into video list item component * ! Fix playlist data loading issue on new windows * ! Fix user playlist data parsing * * Ensure playlist view rerender on video additonal removal for displayed playlist * ! Fix icons & moving videos up/down in user playlist * * Don't show move up/down buttons when cannot be done * * Make user playlist view filtering function now works for filtering playlists * ! Fix style of prompt from any button within playlist-info component * $ Refactor a function to use early return style * * Disallow empty playlist name when saving in playlist edit mode * * Update add video to playlist prompt to have simple filtering like user playlist view * * Update playlist view to only show video reorder/remove buttons in edit mode With notice message * ! Fix playlist view for remote playlist unnecessary reload on save * ! Fix add to playlist prompt behaviour when some playlists are hidden due to filtering * $ Remove unused watch function arguments * * Update user playlist view create new playlist button position * * Update playlist view to add transitions to video reorder/removal * * Allow playlist with different case to be created * * Update visibility of user playlist related action components according to hide playlist settings Only those visible on video, remote playlist are updated * * Update video items to only show add to playlist buttons on hover * - Remove add to favorites button from video list item component * * Update watch-video-info component to add "add to playlist" button * * Update watch-video-info component to remove "add to favourite" button * * Ensure video thumbnail image displayed in 16/9 aspect ratio Mainly due to YT missing video thumbnail image got different aspect ratio 4/3 * * Update new buttons theme * * Put edit playlist button before copy button * * Move "remove video from playlist" button to most right * * Make video reorder & remove button visible on hover in user playlist view, regardless of "edit mode" * ! Fix video count parsing for user playlist * * Update user playlist to allow duplicate video entries (per video ID) * * Remove extra attributes assignment to video object except `timeAdded` Unintended change * * Update copy playlist button to like adding multiple videos to playlists * * Update copy playlist prompt to prefill title if create new playlist prompt shown * * Ensure all playlists have `playlistName` * $- Remove unused playlist property `removeOnWatched` * * Update read all playlist code to ensure existing "default" playlist properties (_id, protected) have same values as those in default Also fix issue discovered during testing * *- Remove unnecessary code line * * Update playlists from default playlists to be deletable * ! Fix duplicate `timeAdded` value for videos copied from user playlist * ! Fix playlist import (tested with db file exported from this branch) * * Update grid view to only display playlist title up to 255 chars Still can see full title in single playlist view * * Update add video to playlist prompt to only display playlist title up to 255 chars * * Update text of new playlist button to be same as new profile button * * Ignore many extra keys from playlist objectrs Also make data import check for object keys against required keys not key counts * * Disallow playlist import from changing internal playlist ID of existing playlists Existing playlists are matched by playlist name, not by internal playlist ID * * Ensure playlist name & description trimmed when saved * * Add missing change for importing playlist to ignore `protected` * $ Refactor code for "video object has all require keys" * ! Fix style of prompt from any button within playlist-info component again z-index war * * Update some empty message & button text * * Ensure playlist item action buttons are hidden during animations * ! Fix other prompt z-index * * Update `showAddToPlaylistPromptForManyVideos` to throw error when required keys missing from passed in video data * *- Remove unused video property `paid` from playlist related code * *- Remove unused video property `type` from playlist related code * ! Fix duplicate playlist displayed on playlist conversion * *- Remove unused video property `published` from playlist related code * * Don't require & generate property `timeAdded` when display a prompt * *- Remove unused video property `isLive` from playlist related code * ! Fix text * ! Revert code change for debugging only * ! Fix CSS for "Ensure playlist item action buttons are hidden during animations" * * Update add playlist button to be shown for live videos * + Add clear all playlists button * * Update add video to playlist prompt to swap "save" & "create playlist" button * ! Fix playlist view won't load after default playlist added due to lack of playlist * * Show toast message when no playlist selected after pressing save button * * Update add video to playlist prompt to show latest updated playlist first Easier for copying playlist with new playlist(s) * ! Fix watch page when visited via history after viewing the video from a deleted user playlist * ! Fix share buttons emitting user playlist IDs * * Add toast message after removing all playlists * ! Fix remote playlist video list rendering with duplicate videos * ! Fix missing key for some direct child elements under `transition-group` * ! Fix animation introduced to unnecessary elements * ! Prevent video link click during animation * ! Fix playlist creation/removal not reflected in other windows * * Ensure playlist visual selected state in sync with data in parent * * Update add video to playlist prompt to auto select playlists created after prompt shown once * * Update copy playlist button to show warning about not loaded videos when some not loaded yet For remote playlist Won't work for Invidious though (coz no way to load more) * * Update add video prompt to make it easier to access buttons via keyboard * * Make video reorder & remove button always visible in user playlist view * * Make plus button can be focused with tab Side effect is thumbnail link can be focused too (otherwise can't make plus button visible) * * Update add video to playlist prompt to focus on search input on shown * * Accept playlist optional property `createdAt` when importing * * Update playlist view to always show add to playlist button * $ Refactor `inUserPlaylist` Only playlist view would supply `playlistType` * * Improve accessibility for new prompts * * Make edit playlist inputs focused on entering edit mode * * Make most prompts focus back to last focused element on close * $ Use tabindex 0 for prompts Possible tabindex values unnecessary with elements programatically focused * * Update add video to playlist prompt to focus back to search input after new playlist created * * Update ft-list-video to focus back on thumbnail link element after add to playlist prompt closed * ! Fix unable to import duplicate video entries into an existing playlist * ! Fix create playlist prompt looks unclosed after playlist created when opened via add video to playlist prompt * ! Fix duplicate video entry ID when playlist with duplicate videoId entries copied to another playlist * ! Fix issues caused by last merge in e291cc8b41b2273a0d77c9f35ea760f0e0f7ac10 * $ Remove unused imports * ! Fix default playlists added when no playlist stored had no required attributes added on 1st run * ! Fix invalid prop type warning * * Use v-if instead of v-show * $ Just assign bool value instead of if-else * + Update playlists view to add sorting option * $- Remove unnecessary property assignments * ! Fix issues caused by "Remove unnecessary property assignments" * ! Fix issues caused by "Remove unnecessary property assignments" * * Ensure sort by time also fallbacks to playlist name sorting * ! Fix add/remove video does not update playlist last created time * ! Fix multi window playlist sync * * Show filtering input & sorting element when no. of playlist > 1 * * Update upcoming video to allow saving in playlist * ! Fix unable to visit previous video when playing first video in a playlist * * Update sorting options labels * ! Fix add to play prompt max width * ! Fix user playlist view incorrectly sorted playlists by latest updated first when filtered * * Update add to playlist prompt to add sort options * $ Remove unused classname * ! Ensure new playlist button focused after add to playlist prompt closed while thumbnail link unselectable * * Add playlists sort order for last played at, update it on play * ! Fix bug introduced by last merge * ! Fix thumbnail not respecting backend preference * ! Fix empty playlist thumbnail in single playlist view * * Make adding large no. of videos faster * $ Remove unused mapActions entries * $ Remove unused and unusable playlist code for inserting video IDs into a playlist * * Update single playlist view to only show `Remove watched videos` btn when there is any video * ! Fix prompt style issue caused by old branch changes * ! Fix removing video from local playlist remove all entries with same video ID * ! Fix adding video does not have uniqueID & timeAdded set Caused by previous add many video performance fix * ! Fix navigation in user playlist between entries of same video * * Reflect playlist updates on watch page playlist panel * $- Remove outdated incorrect prompt style fix * ! Fix add video to playlist prompt too high when there are too many playlists * ! Fix watch page play next/prev video in local playlist * ! Fix error in online playlist playing * * Keep partial playlist backward compatibility by restoring `type` in persisted playlist videos * ! Fix grid item for playlist to hide external player button for local playlist * * Make history rememeber uniqueId (local playlist video entry) when playing video with local playlist * ! Fix grid item for video in user playlist to hide external player button * ! Fix grid item for video in history with user playlist to hide external player button * ! Fix grid item for video in watch page playlist component with user playlist to hide external player button * * Update watch page to clear `uniqueID` from query when not playing local playlist * ! Fix watch page about user playlist detection on new window * * Reflect playlist updates on watch page playlist panel, even for currently playing video * ! Allow video with local playlist to be played in external player, but without playlist Also add missing fix for WatchVideoInfo * ! Fix external player handling for video in local playlist * ! Fix ft-video having different URLs in links * yarn run lint-style-fix * $ Rename uniqueId to playlistItemId * * Ensure local playlist ID won't conflict with remote playlist ID * - Remove import video while creating playlist related code * * Make text translatable * * Make sort option text translatable * ! Fix reverse condition * $ Just use ?. * Code review changes * Spaces * beforeDestroy * Remove unused methods * Remove infoData * filter > find * avoid importing `crypto` from NodeJS * Compress CSS ruleset * $ Remove useless prefix from key * Use template for element with v-if only * Make playlist selector look more selectable (cursor: pointer) * Translate toast messages and fix remove watched videos from playlist * ! Fix translation * - Remove unused methods * $ Remove workaround for issue which cannot be reproduced anymore * $ Remove remaining useless code following last commit removing workaround * you have no playlist > you have no playlists * CSS use var --horizontal-directionality-coefficient * * Update danger buttons color to primary (like clear search cache button) * ! Fix playlist icon container size * ! Fix sorting in add video to playlist prompt when filtered * $- Update ft-inputs to removed prop input-tabindex * ! Fix vue warning * + Add toggle to export playlist for older FT * * Update tooltip text * ! Fix vue warning * * Update text align * * Remove the extra surrounding spaces * Backtick > quote * - Remove useless prop * Fix tootip in lower width view * Update default filename * * Make tooltip auto-wrap * Revert "* Make tooltip auto-wrap" This reverts commit 7d932b936c7814349e50204a7979d2d0f5b0ea73. * Adjust tooltip styling * * Wait for local playlist loading only when playing with a user playlist * * Wait for local playlist loading only when playing with a user playlist requested Request user playlist can still be absent (but not requested for no playlist or remote playlist) * ! Fix single playlist view cover image having link when no video * ! Workaround create playlist prompt won't close when enter pressed in input box * ! Fix clear text button style * ! Fix copying playlist twice to the same user playlist produces same playlistItemId * ! Fix add video to playlist prompt input box style * ! Fix workaround for "create playlist prompt won't close when enter pressed in input box" * ! Ensure add video to playlist prompt updated when a playlist deleted (in another window) * ! Avoid saving and displaying unwanted video attributes into playlists * ! Fix playlist view for deleted user playlists * ! Fix copying playlist twice to the same user playlist produces same playlistItemId Real fix Cause of issue: updating property of input objects (which is shared across multiple run) * ! Fix search suggestions being blocked by playlist info component in single playlist view * ! Fix warning when reversing playlist in watch view * ! Fix prompt in playlist view (playlistinfo component) not above sidebar * Remove CSS top comments absent in other CSS files * Remove not useful comment for CSS * Float with variable Co-authored-by: Jason <84899178+jasonhenriquez@users.noreply.github.com> * Revert "! Fix clear text button style" This reverts commit 44ed286848e3cdf4c52f29a867fe09964adffd78. * Missing change for Revert "! Fix clear text button style" * $ Remove unused style for ft-playlist-selector * Apply changes from review * * Use $tc for translation entries with different value according to count values * ! Fix playlist link in watch view --------- Co-authored-by: Jason Henriquez <jasonhenriquez@protonmail.com> Co-authored-by: Jason <84899178+jasonhenriquez@users.noreply.github.com>
2024-01-03 19:44:57 +01:00
case SyncEvents.GENERAL.DELETE:
commit('removePlaylist', data)
break
(Multiple) Local Playlist (instead of saving video in one hidden list) (#4234) * ! Fix add/removing videos from favourite list * ! Fix playlist type not passed into video list item component * ! Fix playlist data loading issue on new windows * ! Fix user playlist data parsing * * Ensure playlist view rerender on video additonal removal for displayed playlist * ! Fix icons & moving videos up/down in user playlist * * Don't show move up/down buttons when cannot be done * * Make user playlist view filtering function now works for filtering playlists * ! Fix style of prompt from any button within playlist-info component * $ Refactor a function to use early return style * * Disallow empty playlist name when saving in playlist edit mode * * Update add video to playlist prompt to have simple filtering like user playlist view * * Update playlist view to only show video reorder/remove buttons in edit mode With notice message * ! Fix playlist view for remote playlist unnecessary reload on save * ! Fix add to playlist prompt behaviour when some playlists are hidden due to filtering * $ Remove unused watch function arguments * * Update user playlist view create new playlist button position * * Update playlist view to add transitions to video reorder/removal * * Allow playlist with different case to be created * * Update visibility of user playlist related action components according to hide playlist settings Only those visible on video, remote playlist are updated * * Update video items to only show add to playlist buttons on hover * - Remove add to favorites button from video list item component * * Update watch-video-info component to add "add to playlist" button * * Update watch-video-info component to remove "add to favourite" button * * Ensure video thumbnail image displayed in 16/9 aspect ratio Mainly due to YT missing video thumbnail image got different aspect ratio 4/3 * * Update new buttons theme * * Put edit playlist button before copy button * * Move "remove video from playlist" button to most right * * Make video reorder & remove button visible on hover in user playlist view, regardless of "edit mode" * ! Fix video count parsing for user playlist * * Update user playlist to allow duplicate video entries (per video ID) * * Remove extra attributes assignment to video object except `timeAdded` Unintended change * * Update copy playlist button to like adding multiple videos to playlists * * Update copy playlist prompt to prefill title if create new playlist prompt shown * * Ensure all playlists have `playlistName` * $- Remove unused playlist property `removeOnWatched` * * Update read all playlist code to ensure existing "default" playlist properties (_id, protected) have same values as those in default Also fix issue discovered during testing * *- Remove unnecessary code line * * Update playlists from default playlists to be deletable * ! Fix duplicate `timeAdded` value for videos copied from user playlist * ! Fix playlist import (tested with db file exported from this branch) * * Update grid view to only display playlist title up to 255 chars Still can see full title in single playlist view * * Update add video to playlist prompt to only display playlist title up to 255 chars * * Update text of new playlist button to be same as new profile button * * Ignore many extra keys from playlist objectrs Also make data import check for object keys against required keys not key counts * * Disallow playlist import from changing internal playlist ID of existing playlists Existing playlists are matched by playlist name, not by internal playlist ID * * Ensure playlist name & description trimmed when saved * * Add missing change for importing playlist to ignore `protected` * $ Refactor code for "video object has all require keys" * ! Fix style of prompt from any button within playlist-info component again z-index war * * Update some empty message & button text * * Ensure playlist item action buttons are hidden during animations * ! Fix other prompt z-index * * Update `showAddToPlaylistPromptForManyVideos` to throw error when required keys missing from passed in video data * *- Remove unused video property `paid` from playlist related code * *- Remove unused video property `type` from playlist related code * ! Fix duplicate playlist displayed on playlist conversion * *- Remove unused video property `published` from playlist related code * * Don't require & generate property `timeAdded` when display a prompt * *- Remove unused video property `isLive` from playlist related code * ! Fix text * ! Revert code change for debugging only * ! Fix CSS for "Ensure playlist item action buttons are hidden during animations" * * Update add playlist button to be shown for live videos * + Add clear all playlists button * * Update add video to playlist prompt to swap "save" & "create playlist" button * ! Fix playlist view won't load after default playlist added due to lack of playlist * * Show toast message when no playlist selected after pressing save button * * Update add video to playlist prompt to show latest updated playlist first Easier for copying playlist with new playlist(s) * ! Fix watch page when visited via history after viewing the video from a deleted user playlist * ! Fix share buttons emitting user playlist IDs * * Add toast message after removing all playlists * ! Fix remote playlist video list rendering with duplicate videos * ! Fix missing key for some direct child elements under `transition-group` * ! Fix animation introduced to unnecessary elements * ! Prevent video link click during animation * ! Fix playlist creation/removal not reflected in other windows * * Ensure playlist visual selected state in sync with data in parent * * Update add video to playlist prompt to auto select playlists created after prompt shown once * * Update copy playlist button to show warning about not loaded videos when some not loaded yet For remote playlist Won't work for Invidious though (coz no way to load more) * * Update add video prompt to make it easier to access buttons via keyboard * * Make video reorder & remove button always visible in user playlist view * * Make plus button can be focused with tab Side effect is thumbnail link can be focused too (otherwise can't make plus button visible) * * Update add video to playlist prompt to focus on search input on shown * * Accept playlist optional property `createdAt` when importing * * Update playlist view to always show add to playlist button * $ Refactor `inUserPlaylist` Only playlist view would supply `playlistType` * * Improve accessibility for new prompts * * Make edit playlist inputs focused on entering edit mode * * Make most prompts focus back to last focused element on close * $ Use tabindex 0 for prompts Possible tabindex values unnecessary with elements programatically focused * * Update add video to playlist prompt to focus back to search input after new playlist created * * Update ft-list-video to focus back on thumbnail link element after add to playlist prompt closed * ! Fix unable to import duplicate video entries into an existing playlist * ! Fix create playlist prompt looks unclosed after playlist created when opened via add video to playlist prompt * ! Fix duplicate video entry ID when playlist with duplicate videoId entries copied to another playlist * ! Fix issues caused by last merge in e291cc8b41b2273a0d77c9f35ea760f0e0f7ac10 * $ Remove unused imports * ! Fix default playlists added when no playlist stored had no required attributes added on 1st run * ! Fix invalid prop type warning * * Use v-if instead of v-show * $ Just assign bool value instead of if-else * + Update playlists view to add sorting option * $- Remove unnecessary property assignments * ! Fix issues caused by "Remove unnecessary property assignments" * ! Fix issues caused by "Remove unnecessary property assignments" * * Ensure sort by time also fallbacks to playlist name sorting * ! Fix add/remove video does not update playlist last created time * ! Fix multi window playlist sync * * Show filtering input & sorting element when no. of playlist > 1 * * Update upcoming video to allow saving in playlist * ! Fix unable to visit previous video when playing first video in a playlist * * Update sorting options labels * ! Fix add to play prompt max width * ! Fix user playlist view incorrectly sorted playlists by latest updated first when filtered * * Update add to playlist prompt to add sort options * $ Remove unused classname * ! Ensure new playlist button focused after add to playlist prompt closed while thumbnail link unselectable * * Add playlists sort order for last played at, update it on play * ! Fix bug introduced by last merge * ! Fix thumbnail not respecting backend preference * ! Fix empty playlist thumbnail in single playlist view * * Make adding large no. of videos faster * $ Remove unused mapActions entries * $ Remove unused and unusable playlist code for inserting video IDs into a playlist * * Update single playlist view to only show `Remove watched videos` btn when there is any video * ! Fix prompt style issue caused by old branch changes * ! Fix removing video from local playlist remove all entries with same video ID * ! Fix adding video does not have uniqueID & timeAdded set Caused by previous add many video performance fix * ! Fix navigation in user playlist between entries of same video * * Reflect playlist updates on watch page playlist panel * $- Remove outdated incorrect prompt style fix * ! Fix add video to playlist prompt too high when there are too many playlists * ! Fix watch page play next/prev video in local playlist * ! Fix error in online playlist playing * * Keep partial playlist backward compatibility by restoring `type` in persisted playlist videos * ! Fix grid item for playlist to hide external player button for local playlist * * Make history rememeber uniqueId (local playlist video entry) when playing video with local playlist * ! Fix grid item for video in user playlist to hide external player button * ! Fix grid item for video in history with user playlist to hide external player button * ! Fix grid item for video in watch page playlist component with user playlist to hide external player button * * Update watch page to clear `uniqueID` from query when not playing local playlist * ! Fix watch page about user playlist detection on new window * * Reflect playlist updates on watch page playlist panel, even for currently playing video * ! Allow video with local playlist to be played in external player, but without playlist Also add missing fix for WatchVideoInfo * ! Fix external player handling for video in local playlist * ! Fix ft-video having different URLs in links * yarn run lint-style-fix * $ Rename uniqueId to playlistItemId * * Ensure local playlist ID won't conflict with remote playlist ID * - Remove import video while creating playlist related code * * Make text translatable * * Make sort option text translatable * ! Fix reverse condition * $ Just use ?. * Code review changes * Spaces * beforeDestroy * Remove unused methods * Remove infoData * filter > find * avoid importing `crypto` from NodeJS * Compress CSS ruleset * $ Remove useless prefix from key * Use template for element with v-if only * Make playlist selector look more selectable (cursor: pointer) * Translate toast messages and fix remove watched videos from playlist * ! Fix translation * - Remove unused methods * $ Remove workaround for issue which cannot be reproduced anymore * $ Remove remaining useless code following last commit removing workaround * you have no playlist > you have no playlists * CSS use var --horizontal-directionality-coefficient * * Update danger buttons color to primary (like clear search cache button) * ! Fix playlist icon container size * ! Fix sorting in add video to playlist prompt when filtered * $- Update ft-inputs to removed prop input-tabindex * ! Fix vue warning * + Add toggle to export playlist for older FT * * Update tooltip text * ! Fix vue warning * * Update text align * * Remove the extra surrounding spaces * Backtick > quote * - Remove useless prop * Fix tootip in lower width view * Update default filename * * Make tooltip auto-wrap * Revert "* Make tooltip auto-wrap" This reverts commit 7d932b936c7814349e50204a7979d2d0f5b0ea73. * Adjust tooltip styling * * Wait for local playlist loading only when playing with a user playlist * * Wait for local playlist loading only when playing with a user playlist requested Request user playlist can still be absent (but not requested for no playlist or remote playlist) * ! Fix single playlist view cover image having link when no video * ! Workaround create playlist prompt won't close when enter pressed in input box * ! Fix clear text button style * ! Fix copying playlist twice to the same user playlist produces same playlistItemId * ! Fix add video to playlist prompt input box style * ! Fix workaround for "create playlist prompt won't close when enter pressed in input box" * ! Ensure add video to playlist prompt updated when a playlist deleted (in another window) * ! Avoid saving and displaying unwanted video attributes into playlists * ! Fix playlist view for deleted user playlists * ! Fix copying playlist twice to the same user playlist produces same playlistItemId Real fix Cause of issue: updating property of input objects (which is shared across multiple run) * ! Fix search suggestions being blocked by playlist info component in single playlist view * ! Fix warning when reversing playlist in watch view * ! Fix prompt in playlist view (playlistinfo component) not above sidebar * Remove CSS top comments absent in other CSS files * Remove not useful comment for CSS * Float with variable Co-authored-by: Jason <84899178+jasonhenriquez@users.noreply.github.com> * Revert "! Fix clear text button style" This reverts commit 44ed286848e3cdf4c52f29a867fe09964adffd78. * Missing change for Revert "! Fix clear text button style" * $ Remove unused style for ft-playlist-selector * Apply changes from review * * Use $tc for translation entries with different value according to count values * ! Fix playlist link in watch view --------- Co-authored-by: Jason Henriquez <jasonhenriquez@protonmail.com> Co-authored-by: Jason <84899178+jasonhenriquez@users.noreply.github.com>
2024-01-03 19:44:57 +01:00
case SyncEvents.GENERAL.UPSERT:
commit('upsertPlaylistToList', data)
break
case SyncEvents.PLAYLISTS.UPSERT_VIDEO:
commit('addVideo', data)
break
(Multiple) Local Playlist (instead of saving video in one hidden list) (#4234) * ! Fix add/removing videos from favourite list * ! Fix playlist type not passed into video list item component * ! Fix playlist data loading issue on new windows * ! Fix user playlist data parsing * * Ensure playlist view rerender on video additonal removal for displayed playlist * ! Fix icons & moving videos up/down in user playlist * * Don't show move up/down buttons when cannot be done * * Make user playlist view filtering function now works for filtering playlists * ! Fix style of prompt from any button within playlist-info component * $ Refactor a function to use early return style * * Disallow empty playlist name when saving in playlist edit mode * * Update add video to playlist prompt to have simple filtering like user playlist view * * Update playlist view to only show video reorder/remove buttons in edit mode With notice message * ! Fix playlist view for remote playlist unnecessary reload on save * ! Fix add to playlist prompt behaviour when some playlists are hidden due to filtering * $ Remove unused watch function arguments * * Update user playlist view create new playlist button position * * Update playlist view to add transitions to video reorder/removal * * Allow playlist with different case to be created * * Update visibility of user playlist related action components according to hide playlist settings Only those visible on video, remote playlist are updated * * Update video items to only show add to playlist buttons on hover * - Remove add to favorites button from video list item component * * Update watch-video-info component to add "add to playlist" button * * Update watch-video-info component to remove "add to favourite" button * * Ensure video thumbnail image displayed in 16/9 aspect ratio Mainly due to YT missing video thumbnail image got different aspect ratio 4/3 * * Update new buttons theme * * Put edit playlist button before copy button * * Move "remove video from playlist" button to most right * * Make video reorder & remove button visible on hover in user playlist view, regardless of "edit mode" * ! Fix video count parsing for user playlist * * Update user playlist to allow duplicate video entries (per video ID) * * Remove extra attributes assignment to video object except `timeAdded` Unintended change * * Update copy playlist button to like adding multiple videos to playlists * * Update copy playlist prompt to prefill title if create new playlist prompt shown * * Ensure all playlists have `playlistName` * $- Remove unused playlist property `removeOnWatched` * * Update read all playlist code to ensure existing "default" playlist properties (_id, protected) have same values as those in default Also fix issue discovered during testing * *- Remove unnecessary code line * * Update playlists from default playlists to be deletable * ! Fix duplicate `timeAdded` value for videos copied from user playlist * ! Fix playlist import (tested with db file exported from this branch) * * Update grid view to only display playlist title up to 255 chars Still can see full title in single playlist view * * Update add video to playlist prompt to only display playlist title up to 255 chars * * Update text of new playlist button to be same as new profile button * * Ignore many extra keys from playlist objectrs Also make data import check for object keys against required keys not key counts * * Disallow playlist import from changing internal playlist ID of existing playlists Existing playlists are matched by playlist name, not by internal playlist ID * * Ensure playlist name & description trimmed when saved * * Add missing change for importing playlist to ignore `protected` * $ Refactor code for "video object has all require keys" * ! Fix style of prompt from any button within playlist-info component again z-index war * * Update some empty message & button text * * Ensure playlist item action buttons are hidden during animations * ! Fix other prompt z-index * * Update `showAddToPlaylistPromptForManyVideos` to throw error when required keys missing from passed in video data * *- Remove unused video property `paid` from playlist related code * *- Remove unused video property `type` from playlist related code * ! Fix duplicate playlist displayed on playlist conversion * *- Remove unused video property `published` from playlist related code * * Don't require & generate property `timeAdded` when display a prompt * *- Remove unused video property `isLive` from playlist related code * ! Fix text * ! Revert code change for debugging only * ! Fix CSS for "Ensure playlist item action buttons are hidden during animations" * * Update add playlist button to be shown for live videos * + Add clear all playlists button * * Update add video to playlist prompt to swap "save" & "create playlist" button * ! Fix playlist view won't load after default playlist added due to lack of playlist * * Show toast message when no playlist selected after pressing save button * * Update add video to playlist prompt to show latest updated playlist first Easier for copying playlist with new playlist(s) * ! Fix watch page when visited via history after viewing the video from a deleted user playlist * ! Fix share buttons emitting user playlist IDs * * Add toast message after removing all playlists * ! Fix remote playlist video list rendering with duplicate videos * ! Fix missing key for some direct child elements under `transition-group` * ! Fix animation introduced to unnecessary elements * ! Prevent video link click during animation * ! Fix playlist creation/removal not reflected in other windows * * Ensure playlist visual selected state in sync with data in parent * * Update add video to playlist prompt to auto select playlists created after prompt shown once * * Update copy playlist button to show warning about not loaded videos when some not loaded yet For remote playlist Won't work for Invidious though (coz no way to load more) * * Update add video prompt to make it easier to access buttons via keyboard * * Make video reorder & remove button always visible in user playlist view * * Make plus button can be focused with tab Side effect is thumbnail link can be focused too (otherwise can't make plus button visible) * * Update add video to playlist prompt to focus on search input on shown * * Accept playlist optional property `createdAt` when importing * * Update playlist view to always show add to playlist button * $ Refactor `inUserPlaylist` Only playlist view would supply `playlistType` * * Improve accessibility for new prompts * * Make edit playlist inputs focused on entering edit mode * * Make most prompts focus back to last focused element on close * $ Use tabindex 0 for prompts Possible tabindex values unnecessary with elements programatically focused * * Update add video to playlist prompt to focus back to search input after new playlist created * * Update ft-list-video to focus back on thumbnail link element after add to playlist prompt closed * ! Fix unable to import duplicate video entries into an existing playlist * ! Fix create playlist prompt looks unclosed after playlist created when opened via add video to playlist prompt * ! Fix duplicate video entry ID when playlist with duplicate videoId entries copied to another playlist * ! Fix issues caused by last merge in e291cc8b41b2273a0d77c9f35ea760f0e0f7ac10 * $ Remove unused imports * ! Fix default playlists added when no playlist stored had no required attributes added on 1st run * ! Fix invalid prop type warning * * Use v-if instead of v-show * $ Just assign bool value instead of if-else * + Update playlists view to add sorting option * $- Remove unnecessary property assignments * ! Fix issues caused by "Remove unnecessary property assignments" * ! Fix issues caused by "Remove unnecessary property assignments" * * Ensure sort by time also fallbacks to playlist name sorting * ! Fix add/remove video does not update playlist last created time * ! Fix multi window playlist sync * * Show filtering input & sorting element when no. of playlist > 1 * * Update upcoming video to allow saving in playlist * ! Fix unable to visit previous video when playing first video in a playlist * * Update sorting options labels * ! Fix add to play prompt max width * ! Fix user playlist view incorrectly sorted playlists by latest updated first when filtered * * Update add to playlist prompt to add sort options * $ Remove unused classname * ! Ensure new playlist button focused after add to playlist prompt closed while thumbnail link unselectable * * Add playlists sort order for last played at, update it on play * ! Fix bug introduced by last merge * ! Fix thumbnail not respecting backend preference * ! Fix empty playlist thumbnail in single playlist view * * Make adding large no. of videos faster * $ Remove unused mapActions entries * $ Remove unused and unusable playlist code for inserting video IDs into a playlist * * Update single playlist view to only show `Remove watched videos` btn when there is any video * ! Fix prompt style issue caused by old branch changes * ! Fix removing video from local playlist remove all entries with same video ID * ! Fix adding video does not have uniqueID & timeAdded set Caused by previous add many video performance fix * ! Fix navigation in user playlist between entries of same video * * Reflect playlist updates on watch page playlist panel * $- Remove outdated incorrect prompt style fix * ! Fix add video to playlist prompt too high when there are too many playlists * ! Fix watch page play next/prev video in local playlist * ! Fix error in online playlist playing * * Keep partial playlist backward compatibility by restoring `type` in persisted playlist videos * ! Fix grid item for playlist to hide external player button for local playlist * * Make history rememeber uniqueId (local playlist video entry) when playing video with local playlist * ! Fix grid item for video in user playlist to hide external player button * ! Fix grid item for video in history with user playlist to hide external player button * ! Fix grid item for video in watch page playlist component with user playlist to hide external player button * * Update watch page to clear `uniqueID` from query when not playing local playlist * ! Fix watch page about user playlist detection on new window * * Reflect playlist updates on watch page playlist panel, even for currently playing video * ! Allow video with local playlist to be played in external player, but without playlist Also add missing fix for WatchVideoInfo * ! Fix external player handling for video in local playlist * ! Fix ft-video having different URLs in links * yarn run lint-style-fix * $ Rename uniqueId to playlistItemId * * Ensure local playlist ID won't conflict with remote playlist ID * - Remove import video while creating playlist related code * * Make text translatable * * Make sort option text translatable * ! Fix reverse condition * $ Just use ?. * Code review changes * Spaces * beforeDestroy * Remove unused methods * Remove infoData * filter > find * avoid importing `crypto` from NodeJS * Compress CSS ruleset * $ Remove useless prefix from key * Use template for element with v-if only * Make playlist selector look more selectable (cursor: pointer) * Translate toast messages and fix remove watched videos from playlist * ! Fix translation * - Remove unused methods * $ Remove workaround for issue which cannot be reproduced anymore * $ Remove remaining useless code following last commit removing workaround * you have no playlist > you have no playlists * CSS use var --horizontal-directionality-coefficient * * Update danger buttons color to primary (like clear search cache button) * ! Fix playlist icon container size * ! Fix sorting in add video to playlist prompt when filtered * $- Update ft-inputs to removed prop input-tabindex * ! Fix vue warning * + Add toggle to export playlist for older FT * * Update tooltip text * ! Fix vue warning * * Update text align * * Remove the extra surrounding spaces * Backtick > quote * - Remove useless prop * Fix tootip in lower width view * Update default filename * * Make tooltip auto-wrap * Revert "* Make tooltip auto-wrap" This reverts commit 7d932b936c7814349e50204a7979d2d0f5b0ea73. * Adjust tooltip styling * * Wait for local playlist loading only when playing with a user playlist * * Wait for local playlist loading only when playing with a user playlist requested Request user playlist can still be absent (but not requested for no playlist or remote playlist) * ! Fix single playlist view cover image having link when no video * ! Workaround create playlist prompt won't close when enter pressed in input box * ! Fix clear text button style * ! Fix copying playlist twice to the same user playlist produces same playlistItemId * ! Fix add video to playlist prompt input box style * ! Fix workaround for "create playlist prompt won't close when enter pressed in input box" * ! Ensure add video to playlist prompt updated when a playlist deleted (in another window) * ! Avoid saving and displaying unwanted video attributes into playlists * ! Fix playlist view for deleted user playlists * ! Fix copying playlist twice to the same user playlist produces same playlistItemId Real fix Cause of issue: updating property of input objects (which is shared across multiple run) * ! Fix search suggestions being blocked by playlist info component in single playlist view * ! Fix warning when reversing playlist in watch view * ! Fix prompt in playlist view (playlistinfo component) not above sidebar * Remove CSS top comments absent in other CSS files * Remove not useful comment for CSS * Float with variable Co-authored-by: Jason <84899178+jasonhenriquez@users.noreply.github.com> * Revert "! Fix clear text button style" This reverts commit 44ed286848e3cdf4c52f29a867fe09964adffd78. * Missing change for Revert "! Fix clear text button style" * $ Remove unused style for ft-playlist-selector * Apply changes from review * * Use $tc for translation entries with different value according to count values * ! Fix playlist link in watch view --------- Co-authored-by: Jason Henriquez <jasonhenriquez@protonmail.com> Co-authored-by: Jason <84899178+jasonhenriquez@users.noreply.github.com>
2024-01-03 19:44:57 +01:00
case SyncEvents.PLAYLISTS.UPSERT_VIDEOS:
commit('addVideos', data)
break
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
case SyncEvents.PLAYLISTS.DELETE_VIDEO:
commit('removeVideo', data)
break
default:
console.error('playlists: invalid sync event received')
}
})
}
2020-02-16 19:30:00 +01:00
}
}
/**********************/
/*
* DO NOT TOUCH ANYTHING BELOW
* (unless you plan to change the architecture of this module)
*/
const getters = {}
const mutations = {}
const actions = {}
// Add settings that contain side effects to the state
Object.assign(
state,
Object.fromEntries(
Object.keys(stateWithSideEffects).map(
(key) => [
key,
stateWithSideEffects[key].defaultValue
]
)
)
)
// Build default getters, mutations and actions for every setting id
for (const settingId of Object.keys(state)) {
const getterId = defaultGetterId(settingId)
const mutationId = defaultMutationId(settingId)
const updaterId = defaultUpdaterId(settingId)
const triggerId = defaultSideEffectsTriggerId(settingId)
getters[getterId] = (state) => state[settingId]
mutations[mutationId] = (state, value) => { state[settingId] = value }
// If setting has side effects, generate action to handle them
if (Object.keys(stateWithSideEffects).includes(settingId)) {
actions[triggerId] = stateWithSideEffects[settingId].sideEffectsHandler
}
actions[updaterId] = async ({ commit, dispatch, getters }, value) => {
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
try {
await DBSettingHandlers.upsert(settingId, value)
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 (getters.settingHasSideEffects(settingId)) {
dispatch(triggerId, value)
}
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
commit(mutationId, value)
} catch (errMessage) {
console.error(errMessage)
}
}
}
// Add all custom data/logic to their respective objects
Object.assign(state, customState)
Object.assign(getters, customGetters)
Object.assign(mutations, customMutations)
Object.assign(actions, customActions)
2020-02-16 19:30:00 +01:00
export default {
state,
getters,
actions,
mutations
}