From 15c02baf80b1d04d41f87de006091dacc15cc6ff Mon Sep 17 00:00:00 2001 From: Luca Date: Sun, 14 Mar 2021 20:18:46 +0100 Subject: [PATCH] Started investigating default profile loading inconsistency --- src/renderer/App.js | 37 ++++++++++--------- .../watch-video-info/watch-video-info.js | 1 + src/renderer/store/modules/history.js | 2 +- src/renderer/store/modules/profile.js | 10 +++-- src/renderer/store/modules/settings.js | 1 + 5 files changed, 29 insertions(+), 22 deletions(-) diff --git a/src/renderer/App.js b/src/renderer/App.js index c821fad6..7f97e842 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(() => { + 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/components/watch-video-info/watch-video-info.js b/src/renderer/components/watch-video-info/watch-video-info.js index 0c35afb8..1471c231 100644 --- a/src/renderer/components/watch-video-info/watch-video-info.js +++ b/src/renderer/components/watch-video-info/watch-video-info.js @@ -263,6 +263,7 @@ export default Vue.extend({ const currentProfile = JSON.parse(JSON.stringify(this.profileList[this.activeProfile])) const primaryProfile = JSON.parse(JSON.stringify(this.profileList[0])) + console.log("PRIMARY PROFILE:", primaryProfile) if (this.isSubscribed) { currentProfile.subscriptions = currentProfile.subscriptions.filter((channel) => { diff --git a/src/renderer/store/modules/history.js b/src/renderer/store/modules/history.js index 42088578..24841d16 100644 --- a/src/renderer/store/modules/history.js +++ b/src/renderer/store/modules/history.js @@ -13,7 +13,7 @@ if (window && window.process && window.process.type === 'renderer') { const remote = require('@electron/remote') dbLocation = remote.app.getPath('userData') - + console.log("DB", dbLocation) 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..991bd53a 100644 --- a/src/renderer/store/modules/profile.js +++ b/src/renderer/store/modules/profile.js @@ -27,7 +27,7 @@ const profileDb = new Datastore({ const state = { profileList: [{ _id: 'allChannels', - name: 'All Channels', + name: 'Brudi Channels', bgColor: '#000000', textColor: '#FFFFFF', subscriptions: [] @@ -54,6 +54,7 @@ const actions = { } else { // We want the primary profile to always be first // So sort with that then sort alphabetically by profile name + console.log('PROFILE DB RESULTS', results) const profiles = results.sort((a, b) => { if (a._id === 'allChannels') { return -1 @@ -67,10 +68,13 @@ const actions = { }) if (state.profileList.length < profiles.length) { + console.log("STATE LIST LESS RTHAN PROFILES LENGTH") + console.log(profiles, state.profileList) + console.log("ROOTSTATE:SETTINGDEFATL", rootState.settings.defaultProfile) const profileIndex = profiles.findIndex((profile) => { return profile._id === rootState.settings.defaultProfile }) - + console.log("INDEX", profileIndex) if (profileIndex !== -1) { dispatch('updateActiveProfile', profileIndex) } @@ -103,7 +107,7 @@ const actions = { textColor: textColor, subscriptions: [] } - console.log(defaultProfile) + console.log('DIS DEFAULT', 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..aefb4809 100644 --- a/src/renderer/store/modules/settings.js +++ b/src/renderer/store/modules/settings.js @@ -280,6 +280,7 @@ const actions = { commit('setBackendFallback', result.value) break case 'defaultProfile': + console.log("IN SETTING DEFAULT:", result.value) commit('setDefaultProfile', result.value) break case 'checkForUpdates':