Merge pull request #1114 from GilgusMaximus/defaultProfile

Profile loading inconsistency
This commit is contained in:
Luca Hohmann 2021-03-27 19:11:59 +01:00 committed by GitHub
commit 726b521e38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 171 additions and 166 deletions

View File

@ -85,26 +85,27 @@ export default Vue.extend({
} }
}, },
mounted: function () { mounted: function () {
this.$store.dispatch('grabUserSettings') this.$store.dispatch('grabUserSettings').then((result) => {
this.$store.dispatch('grabHistory') this.$store.dispatch('grabHistory')
this.$store.dispatch('grabAllProfiles', this.$t('Profile.All Channels')) this.$store.dispatch('grabAllProfiles', this.$t('Profile.All Channels'))
this.$store.dispatch('grabAllPlaylists') this.$store.dispatch('grabAllPlaylists')
this.$store.commit('setUsingElectron', useElectron) this.$store.commit('setUsingElectron', useElectron)
this.checkThemeSettings() this.checkThemeSettings()
this.checkLocale() this.checkLocale()
if (useElectron) { if (useElectron) {
console.log('User is using Electron') console.log('User is using Electron')
this.activateKeyboardShortcuts() this.activateKeyboardShortcuts()
this.openAllLinksExternally() this.openAllLinksExternally()
this.enableOpenUrl() this.enableOpenUrl()
this.setBoundsOnClose() this.setBoundsOnClose()
} }
setTimeout(() => { setTimeout(() => {
this.checkForNewUpdates() this.checkForNewUpdates()
this.checkForNewBlogPosts() this.checkForNewBlogPosts()
}, 500) }, 500)
})
}, },
methods: { methods: {
checkLocale: function () { checkLocale: function () {

View File

@ -13,7 +13,6 @@ if (window && window.process && window.process.type === 'renderer') {
const remote = require('@electron/remote') const remote = require('@electron/remote')
dbLocation = remote.app.getPath('userData') dbLocation = remote.app.getPath('userData')
dbLocation = dbLocation + '/history.db' dbLocation = dbLocation + '/history.db'
} else { } else {
dbLocation = 'history.db' dbLocation = 'history.db'

View File

@ -103,7 +103,7 @@ const actions = {
textColor: textColor, textColor: textColor,
subscriptions: [] subscriptions: []
} }
console.log(defaultProfile)
profileDb.update({ _id: 'allChannels' }, defaultProfile, { upsert: true }, (err, numReplaced) => { profileDb.update({ _id: 'allChannels' }, defaultProfile, { upsert: true }, (err, numReplaced) => {
if (!err) { if (!err) {
dispatch('grabAllProfiles') dispatch('grabAllProfiles')

View File

@ -264,152 +264,157 @@ const getters = {
const actions = { const actions = {
grabUserSettings ({ dispatch, commit, rootState }) { grabUserSettings ({ dispatch, commit, rootState }) {
settingsDb.find({}, (err, results) => { return new Promise((resolve, reject) => {
if (!err) { settingsDb.find({}, (err, results) => {
console.log(results) if (!err) {
results.forEach((result) => { console.log(results)
switch (result._id) { results.forEach((result) => {
case 'invidiousInstance': switch (result._id) {
if (result.value === '') { case 'invidiousInstance':
dispatch('updateInvidiousInstance', 'https://invidious.snopyta.org') if (result.value === '') {
} else { dispatch('updateInvidiousInstance', 'https://invidious.snopyta.org')
commit('setInvidiousInstance', result.value) } else {
} commit('setInvidiousInstance', result.value)
break }
case 'backendFallback': break
commit('setBackendFallback', result.value) case 'backendFallback':
break commit('setBackendFallback', result.value)
case 'defaultProfile': break
commit('setDefaultProfile', result.value) case 'defaultProfile':
break console.log('IN SETTING DEFAULT:', result.value)
case 'checkForUpdates': commit('setDefaultProfile', result.value)
commit('setCheckForUpdates', result.value) break
break case 'checkForUpdates':
case 'checkForBlogPosts': commit('setCheckForUpdates', result.value)
commit('setCheckForBlogPosts', result.value) break
break case 'checkForBlogPosts':
case 'enableSearchSuggestions': commit('setCheckForBlogPosts', result.value)
commit('setEnableSearchSuggestions', result.value) break
break case 'enableSearchSuggestions':
case 'backendPreference': commit('setEnableSearchSuggestions', result.value)
commit('setBackendPreference', result.value) break
break case 'backendPreference':
case 'landingPage': commit('setBackendPreference', result.value)
commit('setLandingPage', result.value) break
break case 'landingPage':
case 'region': commit('setLandingPage', result.value)
commit('setRegion', result.value) break
break case 'region':
case 'listType': commit('setRegion', result.value)
commit('setListType', result.value) break
break case 'listType':
case 'thumbnailPreference': commit('setListType', result.value)
commit('setThumbnailPreference', result.value) break
break case 'thumbnailPreference':
case 'barColor': commit('setThumbnailPreference', result.value)
commit('setBarColor', result.value) break
break case 'barColor':
case 'uiScale': commit('setBarColor', result.value)
webframe.setZoomFactor(parseInt(result.value) / 100) break
commit('setUiScale', result.value) case 'uiScale':
break webframe.setZoomFactor(parseInt(result.value) / 100)
case 'disableSmoothScrolling': commit('setUiScale', result.value)
commit('setDisableSmoothScrolling', result.value) break
break case 'disableSmoothScrolling':
case 'hideWatchedSubs': commit('setDisableSmoothScrolling', result.value)
commit('setHideWatchedSubs', result.value) break
break case 'hideWatchedSubs':
case 'useRssFeeds': commit('setHideWatchedSubs', result.value)
commit('setUseRssFeeds', result.value) break
break case 'useRssFeeds':
case 'rememberHistory': commit('setUseRssFeeds', result.value)
commit('setRememberHistory', result.value) break
break case 'rememberHistory':
case 'saveWatchedProgress': commit('setRememberHistory', result.value)
commit('setSaveWatchedProgress', result.value) break
break case 'saveWatchedProgress':
case 'autoplayVideos': commit('setSaveWatchedProgress', result.value)
commit('setAutoplayVideos', result.value) break
break case 'autoplayVideos':
case 'autoplayPlaylists': commit('setAutoplayVideos', result.value)
commit('setAutoplayPlaylists', result.value) break
break case 'autoplayPlaylists':
case 'playNextVideo': commit('setAutoplayPlaylists', result.value)
commit('setPlayNextVideo', result.value) break
break case 'playNextVideo':
case 'enableSubtitles': commit('setPlayNextVideo', result.value)
commit('setEnableSubtitles', result.value) break
break case 'enableSubtitles':
case 'forceLocalBackendForLegacy': commit('setEnableSubtitles', result.value)
commit('setForceLocalBackendForLegacy', result.value) break
break case 'forceLocalBackendForLegacy':
case 'proxyVideos': commit('setForceLocalBackendForLegacy', result.value)
commit('setProxyVideos', result.value) break
break case 'proxyVideos':
case 'useProxy': commit('setProxyVideos', result.value)
commit('setUseProxy', result.value) break
break case 'useProxy':
case 'proxyProtocol': commit('setUseProxy', result.value)
commit('setProxyProtocol', result.value) break
break case 'proxyProtocol':
case 'proxyHostname': commit('setProxyProtocol', result.value)
commit('setProxyHostname', result.value) break
break case 'proxyHostname':
case 'proxyPort': commit('setProxyHostname', result.value)
commit('setProxyPort', result.value) break
break case 'proxyPort':
case 'defaultTheatreMode': commit('setProxyPort', result.value)
commit('setDefaultTheatreMode', result.value) break
break case 'defaultTheatreMode':
case 'defaultInterval': commit('setDefaultTheatreMode', result.value)
commit('setDefaultInterval', result.value) break
break case 'defaultInterval':
case 'defaultVolume': commit('setDefaultInterval', result.value)
commit('setDefaultVolume', result.value) break
sessionStorage.setItem('volume', result.value) case 'defaultVolume':
break commit('setDefaultVolume', result.value)
case 'defaultPlayback': sessionStorage.setItem('volume', result.value)
commit('setDefaultPlayback', result.value) break
break case 'defaultPlayback':
case 'defaultVideoFormat': commit('setDefaultPlayback', result.value)
commit('setDefaultVideoFormat', result.value) break
break case 'defaultVideoFormat':
case 'defaultQuality': commit('setDefaultVideoFormat', result.value)
commit('setDefaultQuality', result.value) break
break case 'defaultQuality':
case 'hideVideoViews': commit('setDefaultQuality', result.value)
commit('setHideVideoViews', result.value) break
break case 'hideVideoViews':
case 'hideVideoLikesAndDislikes': commit('setHideVideoViews', result.value)
commit('setHideVideoLikesAndDislikes', result.value) break
break case 'hideVideoLikesAndDislikes':
case 'hideChannelSubscriptions': commit('setHideVideoLikesAndDislikes', result.value)
commit('setHideChannelSubscriptions', result.value) break
break case 'hideChannelSubscriptions':
case 'hideCommentLikes': commit('setHideChannelSubscriptions', result.value)
commit('setHideCommentLikes', result.value) break
break case 'hideCommentLikes':
case 'hideRecommendedVideos': commit('setHideCommentLikes', result.value)
commit('setHideRecommendedVideos', result.value) break
break case 'hideRecommendedVideos':
case 'hideTrendingVideos': commit('setHideRecommendedVideos', result.value)
commit('setHideTrendingVideos', result.value) break
break case 'hideTrendingVideos':
case 'hidePopularVideos': commit('setHideTrendingVideos', result.value)
commit('setHidePopularVideos', result.value) break
break case 'hidePopularVideos':
case 'hidePlaylists': commit('setHidePopularVideos', result.value)
commit('setHidePlaylists', result.value) break
break case 'hidePlaylists':
case 'hideLiveChat': commit('setHidePlaylists', result.value)
commit('setHideLiveChat', result.value) break
break case 'hideLiveChat':
case 'hideActiveSubscriptions': commit('setHideLiveChat', result.value)
commit('setHideActiveSubscriptions', result.value) break
break case 'hideActiveSubscriptions':
} commit('setHideActiveSubscriptions', result.value)
}) break
} }
})
resolve()
}
reject(err)
})
}) })
}, },