Fix journal ordering (#28)
This commit is contained in:
parent
cbd9114599
commit
0709cabea1
2
src/app/.gitignore
vendored
2
src/app/.gitignore
vendored
@ -21,4 +21,4 @@ yarn-error.log*
|
|||||||
*.sw*
|
*.sw*
|
||||||
|
|
||||||
# Auth0 settings
|
# Auth0 settings
|
||||||
src/auth/auth0-variables.js
|
src/auth/auth0-variables.*
|
@ -50,6 +50,14 @@ const setBearer = async function () {
|
|||||||
}
|
}
|
||||||
/* eslint-enable no-console */
|
/* eslint-enable no-console */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sort journal requests either by asOf or showAfter
|
||||||
|
*/
|
||||||
|
const journalSort = function (a, b) {
|
||||||
|
const sortValue = x => x.showAfter === 0 ? x.asOf : x.showAfter
|
||||||
|
return sortValue(a) - sortValue(b)
|
||||||
|
}
|
||||||
|
|
||||||
export default new Vuex.Store({
|
export default new Vuex.Store({
|
||||||
state: {
|
state: {
|
||||||
user: auth.session.profile,
|
user: auth.session.profile,
|
||||||
@ -62,7 +70,7 @@ export default new Vuex.Store({
|
|||||||
state.isLoadingJournal = flag
|
state.isLoadingJournal = flag
|
||||||
},
|
},
|
||||||
[mutations.LOADED_JOURNAL] (state, journal) {
|
[mutations.LOADED_JOURNAL] (state, journal) {
|
||||||
state.journal = journal
|
state.journal = journal.sort(journalSort)
|
||||||
},
|
},
|
||||||
[mutations.REQUEST_ADDED] (state, newRequest) {
|
[mutations.REQUEST_ADDED] (state, newRequest) {
|
||||||
state.journal.push(newRequest)
|
state.journal.push(newRequest)
|
||||||
|
Loading…
Reference in New Issue
Block a user