Fix journal ordering (#28)

This commit is contained in:
Daniel J. Summers 2019-09-10 06:08:19 -05:00
parent cbd9114599
commit 0709cabea1
2 changed files with 10 additions and 2 deletions

2
src/app/.gitignore vendored
View File

@ -21,4 +21,4 @@ yarn-error.log*
*.sw*
# Auth0 settings
src/auth/auth0-variables.js
src/auth/auth0-variables.*

View File

@ -50,6 +50,14 @@ const setBearer = async function () {
}
/* 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({
state: {
user: auth.session.profile,
@ -62,7 +70,7 @@ export default new Vuex.Store({
state.isLoadingJournal = flag
},
[mutations.LOADED_JOURNAL] (state, journal) {
state.journal = journal
state.journal = journal.sort(journalSort)
},
[mutations.REQUEST_ADDED] (state, newRequest) {
state.journal.push(newRequest)