Skip to content
Snippets Groups Projects
Commit 7b92ca6f authored by lain's avatar lain
Browse files

Update timestamps after fetch.

parent eab256a7
No related branches found
No related tags found
No related merge requests found
import { slice, last, intersectionBy, sortBy, unionBy, toInteger, groupBy, differenceBy, each, find } from 'lodash'
// import moment from 'moment'
import { map, slice, last, intersectionBy, sortBy, unionBy, toInteger, groupBy, differenceBy, each, find } from 'lodash'
import moment from 'moment'
const defaultState = {
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 = {
state: defaultState,
mutations: {
......@@ -99,6 +107,9 @@ const statuses = {
oldTimeline.newStatusCount = 0
oldTimeline.visibleStatuses = slice(oldTimeline.statuses, 0, 50)
},
updateTimestamps (state) {
updateTimestampsInStatuses(state.allStatuses)
}
}
}
......
......@@ -11,7 +11,7 @@ const update = ({store, statuses, timeline, showImmediately}) => {
showImmediately
})
// $ngRedux.dispatch({type: 'UPDATE_TIMESTAMPS'});
store.commit('updateTimestamps')
}
const fetchAndUpdate = ({store, credentials, timeline = 'friends', older = false, showImmediately = false}) => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment