This repository was archived by the owner on Feb 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathstore.js
227 lines (225 loc) · 6.74 KB
/
store.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
import Vue from 'vue'
import Vuex from 'vuex'
import autosave from 'vuex-persistedstate'
Vue.use(Vuex)
export default new Vuex.Store({
plugins: [
autosave()
],
state: {
login: false, // store if user logged in with MM
hiddenThreads: [], // array of threads hidden by user
grabFiles: false, // sfw on (false) or off (true)
autoSwitch: true, // switch theme if sfw mode toggles
theme: 'YotsubaB', // current theme selected
disclaimer: true, // show disclaimer on index page
customCSS: '', // store user's custom CSS
forceAnon: true, // replace user names with Anonymous
userBoards: [], // array of custom board list
showAlert: true, // show alert on voting page
comfyMode: false, // compact mode on/off (t/f)
userPayment: 'none', // preferred payment method
ecoMode: false, // limit autodownload to n MB
ipfsNode: 'ipfs.infura.io', // default IPFS gateway to use
ipfsPort: '5001', // IPFS gateway port
ipfsProto: 'https', // IPFS gateway protocol
customGate: false, // use custom gateway instead
customNode: '', // custom IPFS gateway address
customPort: '', // custom IPFS gateway port
customProto: '', // custom IPFS gateway protocol
/**
* below data is for @dev purpose only
* when users create a board the object
* is written into the "boards" array on
* the smart contract. at the same time
* a new array is created in the "threads"
* object where the object key equals the
* board ticker specified by the user
*/
demo: { // fake smart contract storage
boards:[],
threads: {}
},
reports: []
},
getters: {
getLogin: state => {
return state.login
},
getHidden: state => {
return state.hiddenThreads
},
getGrab: state => {
return state.grabFiles
},
getAutoSwitch: state => {
return state.autoSwitch
},
getTheme: state => {
return state.theme
},
getCustomCss: state => {
return state.customCSS
},
getDisclaimer: state => {
return state.disclaimer
},
getForceAnon: state => {
return state.forceAnon
},
getUserBoards: state => {
return state.userBoards
},
getShowAlert: state => {
return state.showAlert
},
getReports: state => {
return state.reports
},
getComfy: state => {
return state.comfyMode
},
getPayment: state => {
return state.userPayment
},
getEco: state => {
return state.ecoMode
},
getDemo: state => {
return state.demo
},
getIpfsNode: state => {
return state.ipfsNode
},
getIpfsPort: state => {
return state.ipfsPort
},
getIpfsProto: state => {
return state.ipfsProto
},
getCustomGate: state => {
return state.customGate
},
getCustomNode: state => {
return state.customNode
},
getCustomPort: state => {
return state.customPort
},
getCustomProto: state => {
return state.customProto
}
},
mutations: {
mutLogin: (state, payload) => {
state.login = payload
},
mutHidden: (state, payload) => {
if(state.hiddenThreads.includes(payload)){
state.hiddenThreads.splice(state.hiddenThreads.indexOf(payload), 1)
}
else {
state.hiddenThreads.push(payload)
}
},
mutGrab: state => {
state.grabFiles = !state.grabFiles
},
mutAuto: state => {
state.autoSwitch = !state.autoSwitch
},
mutTheme: (state, payload) => {
state.theme = payload
},
mutDisclaimer: state => {
state.disclaimer = !state.disclaimer
},
mutCss: (state, payload) => {
state.customCSS = payload
},
mutAnon: state => {
state.forceAnon = !state.forceAnon
},
mutBoardList: (state, payload) => {
state.userBoards = payload
},
mutBoardListReset: state => {
state.userBoards.length = 0
},
mutAlert: state => {
state.showAlert = !state.showAlert
},
mutReports: (state, payload) => {
state.reports.push(payload)
},
mutReportsRemove: (state, payload) => {
state.reports.splice(state.reports.indexOf(payload), 1)
},
mutComfy: state => {
state.comfyMode = !state.comfyMode
},
mutPayment: (state, payload) => {
state.userPayment = payload
},
mutEco: state => {
state.ecoMode = !state.ecoMode
},
mutThread: (state, payload) => {
state.demo.threads[payload.board].push(payload.body)
},
mutReply: (state, payload) => {
state.demo.threads[payload.board].find(a => a.id === payload.thread).replies.push(payload.body)
},
mutBoard: (state, payload) => {
state.demo.threads[payload.board] = []
state.demo.boards.push({"ticker": payload.board, "punchline": payload.punchline})
},
mutCustomGate: state => {
state.customGate = !state.customGate
}
},
actions: {
setBool: (context, payload) => { // universal action for all boolean
context.commit(payload) // mutations, use mut name as payload
},
setLogin: context => {
context.commit('mutLogin', true)
},
setLogout: context => {
context.commit('mutLogin', false)
},
setHidden: (context, payload) => {
context.commit('mutHidden', payload)
},
setTheme: (context, payload) => {
context.commit('mutTheme', payload)
},
setCss: (context, payload) => {
context.commit('mutCss', payload)
},
setBoardListReset: context => {
context.commit('mutBoardListReset')
},
setBoardList: (context, payload) => {
context.commit('mutBoardList', payload)
},
setReports: (context, payload) => {
context.commit('mutReports', payload)
},
setReportsRemove: (context, payload) => {
context.commit('mutReportsRemove', payload)
},
setPayment: (context, payload) => {
context.commit('mutPayment', payload)
},
setThread: (context, payload) => {
context.commit('mutThread', payload)
},
setReply: (context, payload) => {
context.commit('mutReply', payload)
},
setBoard: (context, payload) => {
context.commit('mutBoard', payload)
}
}
})