Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clear store after clearing cache #635

Merged
merged 2 commits into from
Nov 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/renderer/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,7 @@ export default defineComponent({
this.$error('error', e)
} finally {
this.loading = false
this.$store.commit('media/clearProgress')
}
},
},
Expand Down
3 changes: 3 additions & 0 deletions src/renderer/pages/settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,9 @@ export default defineComponent({
}
this.cacheColor = 'warning'
this.calcCache()

this.$store.commit('media/clear')
this.$store.commit('db/clear')
}
this.loading = false
},
Expand Down
11 changes: 9 additions & 2 deletions src/renderer/store/media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const defaultState: MediaStore = {
ffMpeg: false, // Whether FFmpeg has been initialized
musicFadeOut: '', // The fade out time for shuffle music
meetings: new Map(), // A map of meetings and their media
progress: new Map()
progress: new Map(), // A map with downloadIfRequired() calls. If a file is already downloading, it will be returned from the map
}

export const state = () => Object.assign({}, defaultState)
Expand All @@ -16,7 +16,10 @@ export const mutations: MutationTree<MediaStore> = {
setSongPub(state, pub: string) {
state.songPub = pub
},
setProgress(state, {key, promise }: {key: string, promise: Promise<string>}) {
setProgress(
state,
{ key, promise }: { key: string; promise: Promise<string> }
) {
state.progress.set(key, promise)
},
setFFmpeg(state, ffMpeg: boolean) {
Expand Down Expand Up @@ -110,6 +113,10 @@ export const mutations: MutationTree<MediaStore> = {
},
clear(state) {
state.meetings = new Map()
state.progress = new Map()
},
clearProgress(state) {
state.progress = new Map()
},
}

Expand Down