Quellcode durchsuchen

:recycle: fixing import | refactor flat packing titles

tags/0.9.0
J vor 4 Jahren
Ursprung
Commit
802ed0857b
2 geänderte Dateien mit 15 neuen und 15 gelöschten Zeilen
  1. 1
    0
      vue-theme/src/pages/list.vue
  2. 14
    15
      vue-theme/src/store/modules/arrangements.js

+ 1
- 0
vue-theme/src/pages/list.vue Datei anzeigen

@@ -115,6 +115,7 @@ export default {
115 115
             try {
116 116
                 this.loadingFetched = true
117 117
                 this.page++
118
+                console.log('shouldLoadAll :', this.shouldLoadAllAtOnce, this.type)
118 119
                 const res = await getPosts(
119 120
                     {
120 121
                         limit: this.shouldLoadAllAtOnce ? -1 : this.perPage,

+ 14
- 15
vue-theme/src/store/modules/arrangements.js Datei anzeigen

@@ -1,3 +1,14 @@
1
+import { sortTypes } from '../../utils/helpers'
2
+
3
+const _makeFlatpack = bySort => {
4
+    const flatPacked = []
5
+    Object.keys(bySort).forEach(sort => {
6
+        flatPacked.push({ slug: sort, title: sort, inbetween: true })
7
+        bySort[sort].forEach(post => flatPacked.push(post))
8
+    })
9
+    return flatPacked
10
+}
11
+
1 12
 const _arrangeByMaterial = postsList => {
2 13
     const byMaterial = {
3 14
         clay: []
@@ -8,11 +19,7 @@ const _arrangeByMaterial = postsList => {
8 19
             byMaterial[mat].push(post)
9 20
         })
10 21
     })
11
-    const flatPacked = []
12
-    Object.keys(byMaterial).forEach(material => {
13
-        flatPacked.push({ slug: material, title: material, inbetween: true })
14
-        byMaterial[material].forEach(post => flatPacked.push(post))
15
-    })
22
+    const flatPacked = _makeFlatpack(byMaterial)
16 23
     return flatPacked
17 24
 }
18 25
 
@@ -25,11 +32,7 @@ const _arrangeByType = postsList => {
25 32
             byType[type].push(post)
26 33
         })
27 34
     })
28
-    const flatPacked = []
29
-    Object.keys(byType).forEach(type => {
30
-        flatPacked.push({ slug: type, title: type, inbetween: true })
31
-        byType[type].forEach(post => flatPacked.push(post))
32
-    })
35
+    const flatPacked = _makeFlatpack(byType)
33 36
     return flatPacked
34 37
 }
35 38
 
@@ -62,11 +65,7 @@ const _arrangeByEpisode = postsList => {
62 65
         if(!byEpisode[relatedEpisode]) byEpisode[relatedEpisode] = []
63 66
         byEpisode[relatedEpisode].push(post)
64 67
     })
65
-    const flatPacked = []
66
-    Object.keys(byEpisode).forEach(episode => {
67
-        flatPacked.push({ slug: episode, title: episode, inbetween: true })
68
-        byEpisode[episode].forEach(post => flatPacked.push(post))
69
-    })
68
+    const flatPacked = _makeFlatpack(byEpisode)
70 69
     return flatPacked
71 70
 }
72 71
 

Laden…
Abbrechen
Speichern