diff --git a/src/modules/statuses.js b/src/modules/statuses.js index dc0b224b50..b042769491 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -1,5 +1,5 @@ -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) } } } diff --git a/src/services/timeline_fetcher/timeline_fetcher.service.js b/src/services/timeline_fetcher/timeline_fetcher.service.js index 80bcb415c8..a3d9b9d10c 100644 --- a/src/services/timeline_fetcher/timeline_fetcher.service.js +++ b/src/services/timeline_fetcher/timeline_fetcher.service.js @@ -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}) => {