|
|
@@ -3,11 +3,13 @@ import { sortTypes } from '../../utils/helpers'
|
|
3
|
3
|
const _insertInBetweens = bySort => {
|
|
4
|
4
|
const postListWithInBetweens = []
|
|
5
|
5
|
Object.keys(bySort).forEach(term => {
|
|
6
|
|
- postListWithInBetweens.push({
|
|
7
|
|
- slug: term,
|
|
8
|
|
- title: term,
|
|
9
|
|
- inbetween: true
|
|
10
|
|
- })
|
|
|
6
|
+ if(term) {
|
|
|
7
|
+ postListWithInBetweens.push({
|
|
|
8
|
+ slug: term,
|
|
|
9
|
+ title: term,
|
|
|
10
|
+ inbetween: true
|
|
|
11
|
+ })
|
|
|
12
|
+ }
|
|
11
|
13
|
bySort[term].forEach(post => postListWithInBetweens.push(post))
|
|
12
|
14
|
})
|
|
13
|
15
|
return postListWithInBetweens
|
|
|
@@ -40,8 +42,7 @@ const _arrangeByType = postsList => {
|
|
40
|
42
|
return flatPacked
|
|
41
|
43
|
}
|
|
42
|
44
|
|
|
43
|
|
-let seenTitles = []
|
|
44
|
|
-const _arrangeByAlpha = postsList => {
|
|
|
45
|
+const _arrangeByAlpha = (postsList, seenTitles) => {
|
|
45
|
46
|
const alphabet = [...'9abcdefghijklmnopqrstuvwxyz']
|
|
46
|
47
|
const flatPacked = []
|
|
47
|
48
|
|
|
|
@@ -60,7 +61,6 @@ const _arrangeByAlpha = postsList => {
|
|
60
|
61
|
storeTitle(alphabet[charaIndex])
|
|
61
|
62
|
flatPacked.push(post)
|
|
62
|
63
|
})
|
|
63
|
|
- seenTitles = []
|
|
64
|
64
|
return flatPacked
|
|
65
|
65
|
}
|
|
66
|
66
|
|
|
|
@@ -75,7 +75,7 @@ const _arrangeByEpisode = postsList => {
|
|
75
|
75
|
return flatPacked
|
|
76
|
76
|
}
|
|
77
|
77
|
|
|
78
|
|
-const repackBySort = (postsList, sortedBy) => {
|
|
|
78
|
+const repackBySort = (postsList, sortedBy, seenTitles) => {
|
|
79
|
79
|
let repacked = postsList
|
|
80
|
80
|
if(sortedBy == sortTypes.material) {
|
|
81
|
81
|
repacked = _arrangeByMaterial(postsList)
|
|
|
@@ -84,7 +84,7 @@ const repackBySort = (postsList, sortedBy) => {
|
|
84
|
84
|
} else if(sortedBy == sortTypes.subtype) {
|
|
85
|
85
|
repacked = _arrangeByType(postsList)
|
|
86
|
86
|
} else if(sortedBy == sortTypes.alpha) {
|
|
87
|
|
- repacked = _arrangeByAlpha(postsList)
|
|
|
87
|
+ repacked = _arrangeByAlpha(postsList, seenTitles)
|
|
88
|
88
|
}
|
|
89
|
89
|
return repacked
|
|
90
|
90
|
}
|