Started investigating default profile loading inconsistency

This commit is contained in:
Luca 2021-03-14 20:18:46 +01:00
parent ca4fc9974f
commit 24d12a4357
5 changed files with 29 additions and 22 deletions

View File

@ -85,26 +85,27 @@ export default Vue.extend({
} }
}, },
mounted: function () { mounted: function () {
this.$store.dispatch('grabUserSettings') this.$store.dispatch('grabUserSettings').then(() => {
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

@ -263,6 +263,7 @@ export default Vue.extend({
const currentProfile = JSON.parse(JSON.stringify(this.profileList[this.activeProfile])) const currentProfile = JSON.parse(JSON.stringify(this.profileList[this.activeProfile]))
const primaryProfile = JSON.parse(JSON.stringify(this.profileList[0])) const primaryProfile = JSON.parse(JSON.stringify(this.profileList[0]))
console.log("PRIMARY PROFILE:", primaryProfile)
if (this.isSubscribed) { if (this.isSubscribed) {
currentProfile.subscriptions = currentProfile.subscriptions.filter((channel) => { currentProfile.subscriptions = currentProfile.subscriptions.filter((channel) => {

View File

@ -13,7 +13,7 @@ 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')
console.log("DB", dbLocation)
dbLocation = dbLocation + '/history.db' dbLocation = dbLocation + '/history.db'
} else { } else {
dbLocation = 'history.db' dbLocation = 'history.db'

View File

@ -27,7 +27,7 @@ const profileDb = new Datastore({
const state = { const state = {
profileList: [{ profileList: [{
_id: 'allChannels', _id: 'allChannels',
name: 'All Channels', name: 'Brudi Channels',
bgColor: '#000000', bgColor: '#000000',
textColor: '#FFFFFF', textColor: '#FFFFFF',
subscriptions: [] subscriptions: []
@ -54,6 +54,7 @@ const actions = {
} else { } else {
// We want the primary profile to always be first // We want the primary profile to always be first
// So sort with that then sort alphabetically by profile name // So sort with that then sort alphabetically by profile name
console.log('PROFILE DB RESULTS', results)
const profiles = results.sort((a, b) => { const profiles = results.sort((a, b) => {
if (a._id === 'allChannels') { if (a._id === 'allChannels') {
return -1 return -1
@ -67,10 +68,13 @@ const actions = {
}) })
if (state.profileList.length < profiles.length) { 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) => { const profileIndex = profiles.findIndex((profile) => {
return profile._id === rootState.settings.defaultProfile return profile._id === rootState.settings.defaultProfile
}) })
console.log("INDEX", profileIndex)
if (profileIndex !== -1) { if (profileIndex !== -1) {
dispatch('updateActiveProfile', profileIndex) dispatch('updateActiveProfile', profileIndex)
} }
@ -103,7 +107,7 @@ const actions = {
textColor: textColor, textColor: textColor,
subscriptions: [] subscriptions: []
} }
console.log(defaultProfile) console.log('DIS DEFAULT', 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

@ -280,6 +280,7 @@ const actions = {
commit('setBackendFallback', result.value) commit('setBackendFallback', result.value)
break break
case 'defaultProfile': case 'defaultProfile':
console.log("IN SETTING DEFAULT:", result.value)
commit('setDefaultProfile', result.value) commit('setDefaultProfile', result.value)
break break
case 'checkForUpdates': case 'checkForUpdates':