1
1
import { ActionTree , GetterTree } from "vuex" ;
2
2
3
+ import ManagerSettings from "../../r2mm/manager/ManagerSettings" ;
3
4
import { State as RootState } from "../../store" ;
4
5
5
6
interface DownloadProgress {
@@ -21,6 +22,7 @@ interface UpdateObject {
21
22
22
23
interface State {
23
24
allDownloads : DownloadProgress [ ] ,
25
+ ignoreCache : boolean ,
24
26
isModProgressModalOpen : boolean ,
25
27
}
26
28
@@ -32,6 +34,7 @@ export const DownloadModule = {
32
34
33
35
state : ( ) : State => ( {
34
36
allDownloads : [ ] ,
37
+ ignoreCache : false ,
35
38
isModProgressModalOpen : false ,
36
39
} ) ,
37
40
@@ -49,6 +52,11 @@ export const DownloadModule = {
49
52
state . allDownloads = [ ...state . allDownloads , downloadObject ] ;
50
53
return assignId ;
51
54
} ,
55
+ async toggleIgnoreCache ( { commit, rootGetters} ) {
56
+ const settings : ManagerSettings = rootGetters [ 'settings' ] ;
57
+ settings . setIgnoreCache ( ! settings . getContext ( ) . global . ignoreCache ) ;
58
+ commit ( 'setIgnoreCacheVuexOnly' , settings . getContext ( ) . global . ignoreCache ) ;
59
+ } ,
52
60
} ,
53
61
54
62
getters : < GetterTree < State , RootState > > {
@@ -104,6 +112,10 @@ export const DownloadModule = {
104
112
newDownloads [ index ] = { ...newDownloads [ index ] , ...update } ;
105
113
state . allDownloads = newDownloads ;
106
114
} ,
115
+ // Use actions.toggleIngoreCache to store the setting persistently.
116
+ setIgnoreCacheVuexOnly ( state : State , ignoreCache : boolean ) {
117
+ state . ignoreCache = ignoreCache ;
118
+ } ,
107
119
setIsModProgressModalOpen ( state : State , isModProgressModalOpen : boolean ) {
108
120
state . isModProgressModalOpen = isModProgressModalOpen ;
109
121
}
0 commit comments