Fix journal ordering fix (#28 again)

This commit is contained in:
Daniel J. Summers 2019-09-26 20:46:08 -05:00
parent 0709cabea1
commit 2bf54136ca

View File

@ -50,19 +50,22 @@ const setBearer = async function () {
} }
/* eslint-enable no-console */ /* eslint-enable no-console */
/**
* Get the sort value for a prayer request
* @param x The prayer request
*/
const sortValue = x => x.showAfter === 0 ? x.asOf : x.showAfter
/** /**
* Sort journal requests either by asOf or showAfter * Sort journal requests either by asOf or showAfter
*/ */
const journalSort = function (a, b) { const journalSort = (a, b) => sortValue(a) - sortValue(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,
isAuthenticated: auth.isAuthenticated(), isAuthenticated: auth.isAuthenticated(),
journal: {}, journal: [],
isLoadingJournal: false isLoadingJournal: false
}, },
mutations: { mutations: {
@ -115,7 +118,7 @@ export default new Vuex.Store({
} }
}, },
async [actions.LOAD_JOURNAL] ({ commit }, progress) { async [actions.LOAD_JOURNAL] ({ commit }, progress) {
commit(mutations.LOADED_JOURNAL, {}) commit(mutations.LOADED_JOURNAL, [])
progress.$emit('show', 'query') progress.$emit('show', 'query')
commit(mutations.LOADING_JOURNAL, true) commit(mutations.LOADING_JOURNAL, true)
await setBearer() await setBearer()