Sfoglia il codice sorgente

:recycle: consolidating some module code

tags/0.9.0
J 4 anni fa
parent
commit
fc51bcf09a

+ 8
- 0
vue-theme/src/store/modules/arrangements.js Vedi File

@@ -82,7 +82,15 @@ const repackBySort = (postsList, sortedBy) => {
82 82
     return repacked
83 83
 }
84 84
 
85
+const allBySlug = state => {
86
+    return Object.values(state.all).reduce((bySlug, post) => {
87
+        bySlug[post.slug] = post
88
+        return bySlug
89
+    }, {})
90
+}
91
+
85 92
 export {
93
+    allBySlug,
86 94
     repackBySort,
87 95
     _arrangeByMaterial,
88 96
     _arrangeByType,

+ 2
- 6
vue-theme/src/store/modules/artist.js Vedi File

@@ -1,6 +1,6 @@
1 1
 import api from '../../utils/api'
2 2
 import { sortTypes } from '../../utils/helpers'
3
-import { repackBySort } from './arrangements'
3
+import { allBySlug, repackBySort } from './arrangements'
4 4
 
5 5
 const state = {
6 6
     all: [],
@@ -11,11 +11,7 @@ const state = {
11 11
 
12 12
 const getters = {
13 13
     allArtists: state => state.all,
14
-    allArtistsBySlug: state =>
15
-        Object.values(state.all).reduce((bySlug, artist) => {
16
-            bySlug[artist.slug] = artist
17
-            return bySlug
18
-        }, {}),
14
+    allArtistsBySlug: state => allBySlug(state),
19 15
     allArtistsLoaded: state => state.loaded,
20 16
 }
21 17
 

+ 2
- 5
vue-theme/src/store/modules/episode.js Vedi File

@@ -1,4 +1,5 @@
1 1
 import api from '../../utils/api'
2
+import { allBySlug } from './arrangements'
2 3
 
3 4
 const state = {
4 5
     all: [],
@@ -8,11 +9,7 @@ const state = {
8 9
 
9 10
 const getters = {
10 11
     allEpisodes: state => state.all,
11
-    allEpisodesBySlug: state =>
12
-        Object.values(state.all).reduce((bySlug, episode) => {
13
-            bySlug[episode.slug] = episode
14
-            return bySlug
15
-        }, {}),
12
+    allEpisodesBySlug: state => allBySlug(state),
16 13
     allEpisodesLoaded: state => state.loaded,
17 14
 }
18 15
 

+ 2
- 7
vue-theme/src/store/modules/guide.js Vedi File

@@ -1,6 +1,5 @@
1 1
 import api from '../../utils/api'
2
-import { sortTypes } from '../../utils/helpers'
3
-import { repackBySort } from './arrangements'
2
+import { allBySlug, repackBySort } from './arrangements'
4 3
 
5 4
 const state = {
6 5
     all: [],
@@ -10,11 +9,7 @@ const state = {
10 9
 
11 10
 const getters = {
12 11
     allGuides: state => state.all,
13
-    allGuidesBySlug: state =>
14
-        Object.values(state.all).reduce((bySlug, guide) => {
15
-            bySlug[guide.slug] = guide
16
-            return bySlug
17
-        }, {}),
12
+    allGuidesBySlug: state => allBySlug(state),
18 13
     allGuidesLoaded: state => state.loaded,
19 14
 }
20 15
 

+ 3
- 6
vue-theme/src/store/modules/object.js Vedi File

@@ -1,4 +1,5 @@
1 1
 import api from '../../utils/api'
2
+import { allBySlug, repackBySort } from './arrangements'
2 3
 
3 4
 const state = {
4 5
     all: [],
@@ -8,11 +9,7 @@ const state = {
8 9
 
9 10
 const getters = {
10 11
     allObjects: state => state.all,
11
-    allObjectsBySlug: state =>
12
-        Object.values(state.all).reduce((bySlug, object) => {
13
-            bySlug[object.slug] = object
14
-            return bySlug
15
-        }, {}),
12
+    allObjectsBySlug: state => allBySlug(state),
16 13
     allObjectsLoaded: state => state.loaded,
17 14
 }
18 15
 
@@ -21,7 +18,7 @@ const actions = {
21 18
         commit('CLEAR_OBJECTS')
22 19
         commit('OBJECTS_LOADED', false)
23 20
         const storeFetch = (objects => {
24
-            let repacked = objects
21
+            let repacked = repackBySort(objects, sortType)
25 22
             commit('STORE_FETCHED_OBJECTS', { objects: repacked })
26 23
             commit('OBJECTS_LOADED', true)
27 24
         })

+ 3
- 6
vue-theme/src/store/modules/publication.js Vedi File

@@ -1,4 +1,5 @@
1 1
 import api from '../../utils/api'
2
+import { allBySlug, repackBySort } from './arrangements'
2 3
 
3 4
 const state = {
4 5
     all: [],
@@ -8,11 +9,7 @@ const state = {
8 9
 
9 10
 const getters = {
10 11
     allPublications: state => state.all,
11
-    allPublicationsBySlug: state =>
12
-        Publication.values(state.all).reduce((bySlug, publication) => {
13
-            bySlug[publication.slug] = publication
14
-            return bySlug
15
-        }, {}),
12
+    allPublicationsBySlug: state => allBySlug(state),
16 13
     allPublicationsLoaded: state => state.loaded,
17 14
 }
18 15
 
@@ -21,7 +18,7 @@ const actions = {
21 18
         commit('CLEAR_PUBLICATIONS')
22 19
         commit('PUBLICATIONS_LOADED', false)
23 20
         const storeFetch = (publications => {
24
-            let repacked = publications
21
+            let repacked = repackBySort(publications, sortType)
25 22
             commit('STORE_FETCHED_PUBLICATIONS', { publications: repacked })
26 23
             commit('PUBLICATIONS_LOADED', true)
27 24
         })

+ 2
- 6
vue-theme/src/store/modules/short.js Vedi File

@@ -1,5 +1,5 @@
1 1
 import api from '../../utils/api'
2
-import { repackBySort } from './arrangements'
2
+import { allBySlug, repackBySort } from './arrangements'
3 3
 
4 4
 const state = {
5 5
     all: [],
@@ -9,11 +9,7 @@ const state = {
9 9
 
10 10
 const getters = {
11 11
     allShorts: state => state.all,
12
-    allShortsBySlug: state =>
13
-        Object.values(state.all).reduce((bySlug, short) => {
14
-            bySlug[short.slug] = short
15
-            return bySlug
16
-        }, {}),
12
+    allShortsBySlug: state => allBySlug(state),
17 13
     allShortsLoaded: state => state.loaded,
18 14
 }
19 15
 

+ 2
- 6
vue-theme/src/store/modules/technique.js Vedi File

@@ -1,5 +1,5 @@
1 1
 import api from '../../utils/api'
2
-import { repackBySort } from './arrangements'
2
+import { allBySlug, repackBySort } from './arrangements'
3 3
 
4 4
 const state = {
5 5
     all: [],
@@ -9,11 +9,7 @@ const state = {
9 9
 
10 10
 const getters = {
11 11
     allTechniques: state => state.all,
12
-    allTechniquesBySlug: state =>
13
-        Object.values(state.all).reduce((bySlug, technique) => {
14
-            bySlug[technique.slug] = technique
15
-            return bySlug
16
-        }, {}),
12
+    allTechniquesBySlug: state => allBySlug(state),
17 13
     allTechniquesLoaded: state => state.loaded,
18 14
 }
19 15
 

Loading…
Annulla
Salva