From de25c4667095938a1437c357fec64c7936bef939 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Fri, 18 Nov 2016 22:56:20 +0100 Subject: [PATCH] addNewStatuses: mutation -> action This is to add the current user. --- .../status_poster/status_poster.service.js | 35 +----------- .../timeline_fetcher.service.js | 54 +------------------ 2 files changed, 2 insertions(+), 87 deletions(-) diff --git a/src/services/status_poster/status_poster.service.js b/src/services/status_poster/status_poster.service.js index 2a32454150..1cc97c7a57 100644 --- a/src/services/status_poster/status_poster.service.js +++ b/src/services/status_poster/status_poster.service.js @@ -7,7 +7,7 @@ const postStatus = ({ store, status, media = [], inReplyToStatusId = undefined } return apiService.postStatus({credentials: store.state.users.currentUser.credentials, status, mediaIds, inReplyToStatusId}) .then((data) => data.json()) .then((data) => { - store.commit('addNewStatuses', + store.dispatch('addNewStatuses', { statuses: [data], timeline: 'friends', showImmediately: true }) }) } @@ -30,36 +30,3 @@ const statusPosterService = { } export default statusPosterService - -// const statusPosterServiceFactory = (apiService, $ngRedux) => { -// const postStatus = ({status, media = [], in_reply_to_status_id = undefined}) => { -// const mediaIds = map(media, 'id'); - -// return apiService.postStatus({status, mediaIds, in_reply_to_status_id}). -// then((data) => data.json()). -// then((data) => { -// $ngRedux.dispatch({type: 'ADD_NEW_STATUSES', data: { statuses: [data], timeline: 'friends', showImmediately: true }}); -// }); -// }; - -// const uploadMedia = (formData) => { -// return apiService.uploadMedia(formData).then((xml) => { -// return { -// id: xml.getElementsByTagName('media_id')[0].textContent, -// url: xml.getElementsByTagName('media_url')[0].textContent, -// image: xml.getElementsByTagName('atom:link')[0].getAttribute('href') -// }; -// }); -// }; - -// const statusPosterService = { -// postStatus, -// uploadMedia -// }; - -// return statusPosterService; -// }; - -// statusPosterServiceFactory.$inject = ['apiService', '$ngRedux']; - -// export default statusPosterServiceFactory; diff --git a/src/services/timeline_fetcher/timeline_fetcher.service.js b/src/services/timeline_fetcher/timeline_fetcher.service.js index 8a39eeb50a..5e64d0db24 100644 --- a/src/services/timeline_fetcher/timeline_fetcher.service.js +++ b/src/services/timeline_fetcher/timeline_fetcher.service.js @@ -5,7 +5,7 @@ import apiService from '../api/api.service.js' const update = ({store, statuses, timeline, showImmediately}) => { const ccTimeline = camelCase(timeline) - store.commit('addNewStatuses', { + store.dispatch('addNewStatuses', { timeline: ccTimeline, statuses, showImmediately @@ -41,55 +41,3 @@ const timelineFetcher = { } export default timelineFetcher - -// const timelineFetcherServiceFactory = ($ngRedux, apiService, $interval) => { -// let fetcher; - -// const update = ({statuses, timeline, showImmediately}) => { -// const ccTimeline = camelCase(timeline); - -// const action = { -// type: 'ADD_NEW_STATUSES', -// data: { -// statuses, -// timeline: ccTimeline, -// showImmediately -// } -// }; - -// $ngRedux.dispatch(action); -// $ngRedux.dispatch({type: 'UPDATE_TIMESTAMPS'}); -// }; - -// const fetchAndUpdate = ({timeline = 'friends', older = false, showImmediately = false}) => { -// const args = { timeline }; -// const timelineData = $ngRedux.getState().statuses.timelines[camelCase(timeline)]; - -// if(older) { -// args['until'] = timelineData.minVisibleId; -// } else { -// args['since'] = timelineData.maxId; -// } - -// apiService.fetchTimeline(args). -// then((statuses) => update({statuses, timeline, showImmediately})); -// }; - -// const startFetching = ({timeline = 'friends'}) => { -// fetchAndUpdate({timeline, showImmediately: true}); - -// const boundFetchAndUpdate = () => fetchAndUpdate({timeline}); -// fetcher = $interval(boundFetchAndUpdate, 10000); -// }; - -// const timelineFetcherService = { -// startFetching, -// fetchAndUpdate -// }; - -// return timelineFetcherService; -// }; - -// timelineFetcherServiceFactory.$inject = ['$ngRedux', 'apiService', '$interval']; - -// export default timelineFetcherServiceFactory;