diff --git a/src/renderer/App.js b/src/renderer/App.js index c821fad6..eca320ba 100644 --- a/src/renderer/App.js +++ b/src/renderer/App.js @@ -85,26 +85,27 @@ export default Vue.extend({ } }, mounted: function () { - this.$store.dispatch('grabUserSettings') - this.$store.dispatch('grabHistory') - this.$store.dispatch('grabAllProfiles', this.$t('Profile.All Channels')) - this.$store.dispatch('grabAllPlaylists') - this.$store.commit('setUsingElectron', useElectron) - this.checkThemeSettings() - this.checkLocale() + this.$store.dispatch('grabUserSettings').then((result) => { + this.$store.dispatch('grabHistory') + this.$store.dispatch('grabAllProfiles', this.$t('Profile.All Channels')) + this.$store.dispatch('grabAllPlaylists') + this.$store.commit('setUsingElectron', useElectron) + this.checkThemeSettings() + this.checkLocale() - if (useElectron) { - console.log('User is using Electron') - this.activateKeyboardShortcuts() - this.openAllLinksExternally() - this.enableOpenUrl() - this.setBoundsOnClose() - } + if (useElectron) { + console.log('User is using Electron') + this.activateKeyboardShortcuts() + this.openAllLinksExternally() + this.enableOpenUrl() + this.setBoundsOnClose() + } - setTimeout(() => { - this.checkForNewUpdates() - this.checkForNewBlogPosts() - }, 500) + setTimeout(() => { + this.checkForNewUpdates() + this.checkForNewBlogPosts() + }, 500) + }) }, methods: { checkLocale: function () { diff --git a/src/renderer/store/modules/history.js b/src/renderer/store/modules/history.js index 42088578..3869c0c5 100644 --- a/src/renderer/store/modules/history.js +++ b/src/renderer/store/modules/history.js @@ -13,7 +13,6 @@ if (window && window.process && window.process.type === 'renderer') { const remote = require('@electron/remote') dbLocation = remote.app.getPath('userData') - dbLocation = dbLocation + '/history.db' } else { dbLocation = 'history.db' diff --git a/src/renderer/store/modules/profile.js b/src/renderer/store/modules/profile.js index fe5b25fd..d934aedd 100644 --- a/src/renderer/store/modules/profile.js +++ b/src/renderer/store/modules/profile.js @@ -103,7 +103,7 @@ const actions = { textColor: textColor, subscriptions: [] } - console.log(defaultProfile) + profileDb.update({ _id: 'allChannels' }, defaultProfile, { upsert: true }, (err, numReplaced) => { if (!err) { dispatch('grabAllProfiles') diff --git a/src/renderer/store/modules/settings.js b/src/renderer/store/modules/settings.js index bb4d2d2d..1c427b05 100644 --- a/src/renderer/store/modules/settings.js +++ b/src/renderer/store/modules/settings.js @@ -264,152 +264,157 @@ const getters = { const actions = { grabUserSettings ({ dispatch, commit, rootState }) { - settingsDb.find({}, (err, results) => { - if (!err) { - console.log(results) - results.forEach((result) => { - switch (result._id) { - case 'invidiousInstance': - if (result.value === '') { - dispatch('updateInvidiousInstance', 'https://invidious.snopyta.org') - } else { - commit('setInvidiousInstance', result.value) - } - break - case 'backendFallback': - commit('setBackendFallback', result.value) - break - case 'defaultProfile': - commit('setDefaultProfile', result.value) - break - case 'checkForUpdates': - commit('setCheckForUpdates', result.value) - break - case 'checkForBlogPosts': - commit('setCheckForBlogPosts', result.value) - break - case 'enableSearchSuggestions': - commit('setEnableSearchSuggestions', result.value) - break - case 'backendPreference': - commit('setBackendPreference', result.value) - break - case 'landingPage': - commit('setLandingPage', result.value) - break - case 'region': - commit('setRegion', result.value) - break - case 'listType': - commit('setListType', result.value) - break - case 'thumbnailPreference': - commit('setThumbnailPreference', result.value) - break - case 'barColor': - commit('setBarColor', result.value) - break - case 'uiScale': - webframe.setZoomFactor(parseInt(result.value) / 100) - commit('setUiScale', result.value) - break - case 'disableSmoothScrolling': - commit('setDisableSmoothScrolling', result.value) - break - case 'hideWatchedSubs': - commit('setHideWatchedSubs', result.value) - break - case 'useRssFeeds': - commit('setUseRssFeeds', result.value) - break - case 'rememberHistory': - commit('setRememberHistory', result.value) - break - case 'saveWatchedProgress': - commit('setSaveWatchedProgress', result.value) - break - case 'autoplayVideos': - commit('setAutoplayVideos', result.value) - break - case 'autoplayPlaylists': - commit('setAutoplayPlaylists', result.value) - break - case 'playNextVideo': - commit('setPlayNextVideo', result.value) - break - case 'enableSubtitles': - commit('setEnableSubtitles', result.value) - break - case 'forceLocalBackendForLegacy': - commit('setForceLocalBackendForLegacy', result.value) - break - case 'proxyVideos': - commit('setProxyVideos', result.value) - break - case 'useProxy': - commit('setUseProxy', result.value) - break - case 'proxyProtocol': - commit('setProxyProtocol', result.value) - break - case 'proxyHostname': - commit('setProxyHostname', result.value) - break - case 'proxyPort': - commit('setProxyPort', result.value) - break - case 'defaultTheatreMode': - commit('setDefaultTheatreMode', result.value) - break - case 'defaultInterval': - commit('setDefaultInterval', result.value) - break - case 'defaultVolume': - commit('setDefaultVolume', result.value) - sessionStorage.setItem('volume', result.value) - break - case 'defaultPlayback': - commit('setDefaultPlayback', result.value) - break - case 'defaultVideoFormat': - commit('setDefaultVideoFormat', result.value) - break - case 'defaultQuality': - commit('setDefaultQuality', result.value) - break - case 'hideVideoViews': - commit('setHideVideoViews', result.value) - break - case 'hideVideoLikesAndDislikes': - commit('setHideVideoLikesAndDislikes', result.value) - break - case 'hideChannelSubscriptions': - commit('setHideChannelSubscriptions', result.value) - break - case 'hideCommentLikes': - commit('setHideCommentLikes', result.value) - break - case 'hideRecommendedVideos': - commit('setHideRecommendedVideos', result.value) - break - case 'hideTrendingVideos': - commit('setHideTrendingVideos', result.value) - break - case 'hidePopularVideos': - commit('setHidePopularVideos', result.value) - break - case 'hidePlaylists': - commit('setHidePlaylists', result.value) - break - case 'hideLiveChat': - commit('setHideLiveChat', result.value) - break - case 'hideActiveSubscriptions': - commit('setHideActiveSubscriptions', result.value) - break - } - }) - } + return new Promise((resolve, reject) => { + settingsDb.find({}, (err, results) => { + if (!err) { + console.log(results) + results.forEach((result) => { + switch (result._id) { + case 'invidiousInstance': + if (result.value === '') { + dispatch('updateInvidiousInstance', 'https://invidious.snopyta.org') + } else { + commit('setInvidiousInstance', result.value) + } + break + case 'backendFallback': + commit('setBackendFallback', result.value) + break + case 'defaultProfile': + console.log('IN SETTING DEFAULT:', result.value) + commit('setDefaultProfile', result.value) + break + case 'checkForUpdates': + commit('setCheckForUpdates', result.value) + break + case 'checkForBlogPosts': + commit('setCheckForBlogPosts', result.value) + break + case 'enableSearchSuggestions': + commit('setEnableSearchSuggestions', result.value) + break + case 'backendPreference': + commit('setBackendPreference', result.value) + break + case 'landingPage': + commit('setLandingPage', result.value) + break + case 'region': + commit('setRegion', result.value) + break + case 'listType': + commit('setListType', result.value) + break + case 'thumbnailPreference': + commit('setThumbnailPreference', result.value) + break + case 'barColor': + commit('setBarColor', result.value) + break + case 'uiScale': + webframe.setZoomFactor(parseInt(result.value) / 100) + commit('setUiScale', result.value) + break + case 'disableSmoothScrolling': + commit('setDisableSmoothScrolling', result.value) + break + case 'hideWatchedSubs': + commit('setHideWatchedSubs', result.value) + break + case 'useRssFeeds': + commit('setUseRssFeeds', result.value) + break + case 'rememberHistory': + commit('setRememberHistory', result.value) + break + case 'saveWatchedProgress': + commit('setSaveWatchedProgress', result.value) + break + case 'autoplayVideos': + commit('setAutoplayVideos', result.value) + break + case 'autoplayPlaylists': + commit('setAutoplayPlaylists', result.value) + break + case 'playNextVideo': + commit('setPlayNextVideo', result.value) + break + case 'enableSubtitles': + commit('setEnableSubtitles', result.value) + break + case 'forceLocalBackendForLegacy': + commit('setForceLocalBackendForLegacy', result.value) + break + case 'proxyVideos': + commit('setProxyVideos', result.value) + break + case 'useProxy': + commit('setUseProxy', result.value) + break + case 'proxyProtocol': + commit('setProxyProtocol', result.value) + break + case 'proxyHostname': + commit('setProxyHostname', result.value) + break + case 'proxyPort': + commit('setProxyPort', result.value) + break + case 'defaultTheatreMode': + commit('setDefaultTheatreMode', result.value) + break + case 'defaultInterval': + commit('setDefaultInterval', result.value) + break + case 'defaultVolume': + commit('setDefaultVolume', result.value) + sessionStorage.setItem('volume', result.value) + break + case 'defaultPlayback': + commit('setDefaultPlayback', result.value) + break + case 'defaultVideoFormat': + commit('setDefaultVideoFormat', result.value) + break + case 'defaultQuality': + commit('setDefaultQuality', result.value) + break + case 'hideVideoViews': + commit('setHideVideoViews', result.value) + break + case 'hideVideoLikesAndDislikes': + commit('setHideVideoLikesAndDislikes', result.value) + break + case 'hideChannelSubscriptions': + commit('setHideChannelSubscriptions', result.value) + break + case 'hideCommentLikes': + commit('setHideCommentLikes', result.value) + break + case 'hideRecommendedVideos': + commit('setHideRecommendedVideos', result.value) + break + case 'hideTrendingVideos': + commit('setHideTrendingVideos', result.value) + break + case 'hidePopularVideos': + commit('setHidePopularVideos', result.value) + break + case 'hidePlaylists': + commit('setHidePlaylists', result.value) + break + case 'hideLiveChat': + commit('setHideLiveChat', result.value) + break + case 'hideActiveSubscriptions': + commit('setHideActiveSubscriptions', result.value) + break + } + }) + resolve() + } + reject(err) + }) }) },