Update timestamps after fetch.
This commit is contained in:
parent
eab256a7e5
commit
7b92ca6f94
2 changed files with 14 additions and 3 deletions
|
@ -1,5 +1,5 @@
|
||||||
import { slice, last, intersectionBy, sortBy, unionBy, toInteger, groupBy, differenceBy, each, find } from 'lodash'
|
import { map, slice, last, intersectionBy, sortBy, unionBy, toInteger, groupBy, differenceBy, each, find } from 'lodash'
|
||||||
// import moment from 'moment'
|
import moment from 'moment'
|
||||||
|
|
||||||
const defaultState = {
|
const defaultState = {
|
||||||
allStatuses: [],
|
allStatuses: [],
|
||||||
|
@ -87,6 +87,14 @@ const addStatusesToTimeline = (addedStatuses, showImmediately, { statuses, visib
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const updateTimestampsInStatuses = (statuses) => {
|
||||||
|
return map(statuses, (status) => {
|
||||||
|
// Parse date
|
||||||
|
status.created_at_parsed = moment(status.created_at).fromNow()
|
||||||
|
return status
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const statuses = {
|
const statuses = {
|
||||||
state: defaultState,
|
state: defaultState,
|
||||||
mutations: {
|
mutations: {
|
||||||
|
@ -99,6 +107,9 @@ const statuses = {
|
||||||
|
|
||||||
oldTimeline.newStatusCount = 0
|
oldTimeline.newStatusCount = 0
|
||||||
oldTimeline.visibleStatuses = slice(oldTimeline.statuses, 0, 50)
|
oldTimeline.visibleStatuses = slice(oldTimeline.statuses, 0, 50)
|
||||||
|
},
|
||||||
|
updateTimestamps (state) {
|
||||||
|
updateTimestampsInStatuses(state.allStatuses)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ const update = ({store, statuses, timeline, showImmediately}) => {
|
||||||
showImmediately
|
showImmediately
|
||||||
})
|
})
|
||||||
|
|
||||||
// $ngRedux.dispatch({type: 'UPDATE_TIMESTAMPS'});
|
store.commit('updateTimestamps')
|
||||||
}
|
}
|
||||||
|
|
||||||
const fetchAndUpdate = ({store, credentials, timeline = 'friends', older = false, showImmediately = false}) => {
|
const fetchAndUpdate = ({store, credentials, timeline = 'friends', older = false, showImmediately = false}) => {
|
||||||
|
|
Loading…
Reference in a new issue