Skip to content

Commit

Permalink
feat: use localForage as storage
Browse files Browse the repository at this point in the history
  • Loading branch information
AlejandroAkbal committed Apr 11, 2021
1 parent 7c28332 commit e5f960d
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion plugins/vuex-persist.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
import VuexPersistence from 'vuex-persist'

export default ({ store }) => {
export default (context) => {
const {
store,
$localForage,
app: { router },
} = context

// Booru state
new VuexPersistence({
key: 'booru',

storage: $localForage,
asyncStorage: true,

reducer: (state) => ({
booru: {
history: state.booru.history,
Expand All @@ -16,6 +25,9 @@ export default ({ store }) => {
new VuexPersistence({
key: 'vuex',

storage: $localForage,
asyncStorage: true,

reducer: (state) => ({
statistics: state.statistics,
}),
Expand All @@ -25,6 +37,9 @@ export default ({ store }) => {
new VuexPersistence({
key: 'notifications',

storage: $localForage,
asyncStorage: true,

reducer: (state) => ({
notifications: {
// Double because the state and module are named the same
Expand All @@ -39,6 +54,9 @@ export default ({ store }) => {
new VuexPersistence({
key: 'user',

storage: $localForage,
asyncStorage: true,

reducer: (state) => {
const SETTINGS_OBJ = {}

Expand Down

0 comments on commit e5f960d

Please sign in to comment.