aboutsummaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorEdijs <iamedijs@hotmail.com>2019-02-07 16:23:18 -0700
committerEdijs <iamedijs@hotmail.com>2019-02-07 16:23:18 -0700
commit0dc7c45f324c246cc74c6ed55c006c67742c4139 (patch)
tree821558383453a9dcdfdaa452b91ce6307f1f060c /src/modules
parent19870c0b6d4f7cb73e36b16d3c09d2011e6367a9 (diff)
Code refactoring
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/api.js25
-rw-r--r--src/modules/users.js2
2 files changed, 6 insertions, 21 deletions
diff --git a/src/modules/api.js b/src/modules/api.js
index 95782e38..31cb55c6 100644
--- a/src/modules/api.js
+++ b/src/modules/api.js
@@ -1,5 +1,4 @@
import backendInteractorService from '../services/backend_interactor_service/backend_interactor_service.js'
-import { isArray } from 'lodash'
import { Socket } from 'phoenix'
const api = {
@@ -34,26 +33,12 @@ const api = {
}
},
actions: {
- startFetching (store, payload) {
- let userId = false
- let timeline = 'friends'
- let tag = false
-
- if (isArray(payload)) {
- // For user timelines
- timeline = payload[0]
- userId = payload[1]
- } else if (payload.tag) {
- // For tag timelines
- timeline = 'tag'
- tag = payload.tag
- }
-
+ startFetching (store, {timeline = 'friends', tag = false, userId = false}) {
// Don't start fetching if we already are.
- if (!store.state.fetchers[timeline]) {
- const fetcher = store.state.backendInteractor.startFetching({timeline, store, userId, tag})
- store.commit('addFetcher', {timeline, fetcher})
- }
+ if (store.state.fetchers[timeline]) return
+
+ const fetcher = store.state.backendInteractor.startFetching({ timeline, store, userId, tag })
+ store.commit('addFetcher', { timeline, fetcher })
},
stopFetching (store, timeline) {
const fetcher = store.state.fetchers[timeline]
diff --git a/src/modules/users.js b/src/modules/users.js
index ca2e0f31..4d56ec6f 100644
--- a/src/modules/users.js
+++ b/src/modules/users.js
@@ -271,7 +271,7 @@ const users = {
}
// Start getting fresh posts.
- store.dispatch('startFetching', 'friends')
+ store.dispatch('startFetching', { timeline: 'friends' })
// Get user mutes and follower info
store.rootState.api.backendInteractor.fetchMutes().then((mutedUsers) => {