From 7b92ca6f9406fc93868273c7fd755f92443cb0be Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Fri, 28 Oct 2016 15:59:49 +0200 Subject: [PATCH] Update timestamps after fetch. --- src/modules/statuses.js | 15 +++++++++++++-- .../timeline_fetcher/timeline_fetcher.service.js | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) 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}) => {