Skip to content

Commit

Permalink
fix: Initialize the photosLocationFolder on first load
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <[email protected]>
  • Loading branch information
susnux committed Mar 23, 2024
1 parent 7c06c28 commit b33af7d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import faces from './faces.js'
import folders from './folders.js'
import systemtags from './systemtags.js'
import userConfig, { getFolder } from './userConfig.js'
import logger from '../services/logger.js'

Vue.use(Vuex)
export default new Store({
Expand All @@ -51,6 +52,12 @@ export default new Store({

plugins: [
(store) => {
// Initialize the `photosLocationFolder` state
getFolder(store.state.userConfig.photosLocation)
.then((value) => store.commit('updateUserConfig', { key: 'photosLocationFolder', value }))
.catch((error) => logger.error('Could not load photos location', { error }))

// Subscribe the store to load photos location folder when the location was changed
store.subscribe(async (mutation, state) => {
if (mutation.type === 'updateUserConfig' && mutation.payload.key === 'photosLocation') {
const photosLocationFolder = await getFolder(state.userConfig.photosLocation)
Expand Down

0 comments on commit b33af7d

Please sign in to comment.