commit: 8b3799680547fb054112446caca8fa47df5c7612
parent: 377b8988b605111cac6e1b5d6d920283b3ba812b
Author: Shpuld Shpludson <shp@cock.li>
Date: Tue, 19 Nov 2019 14:07:15 +0000
Merge branch 'fix-fetch-follow-request-for-mobile' into 'develop'
Fix follow request for mobile
See merge request pleroma/pleroma-fe!1005
Diffstat:
5 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/src/components/nav_panel/nav_panel.js b/src/components/nav_panel/nav_panel.js
@@ -1,12 +1,7 @@
-import followRequestFetcher from '../../services/follow_request_fetcher/follow_request_fetcher.service'
-
const NavPanel = {
created () {
if (this.currentUser && this.currentUser.locked) {
- const store = this.$store
- const credentials = store.state.users.currentUser.credentials
-
- followRequestFetcher.startFetching({ store, credentials })
+ this.$store.dispatch('startFetchingFollowRequest')
}
},
computed: {
diff --git a/src/components/side_drawer/side_drawer.js b/src/components/side_drawer/side_drawer.js
@@ -10,6 +10,10 @@ const SideDrawer = {
}),
created () {
this.closeGesture = GestureService.swipeGesture(GestureService.DIRECTION_LEFT, this.toggleDrawer)
+
+ if (this.currentUser && this.currentUser.locked) {
+ this.$store.dispatch('startFetchingFollowRequest')
+ }
},
components: { UserCard },
computed: {
diff --git a/src/modules/api.js b/src/modules/api.js
@@ -43,6 +43,13 @@ const api = {
const fetcher = store.state.backendInteractor.startFetchingNotifications({ store })
store.commit('addFetcher', { fetcherName: 'notifications', fetcher })
},
+ startFetchingFollowRequest (store) {
+ // Don't start fetching if we already are.
+ if (store.state.fetchers['followRequest']) return
+
+ const fetcher = store.state.backendInteractor.startFetchingFollowRequest({ store })
+ store.commit('addFetcher', { fetcherName: 'followRequest', fetcher })
+ },
stopFetching (store, fetcherName) {
const fetcher = store.state.fetchers[fetcherName]
window.clearInterval(fetcher)
diff --git a/src/modules/users.js b/src/modules/users.js
@@ -434,6 +434,7 @@ const users = {
store.dispatch('stopFetching', 'friends')
store.commit('setBackendInteractor', backendInteractorService(store.getters.getToken()))
store.dispatch('stopFetching', 'notifications')
+ store.dispatch('stopFetching', 'followRequest')
store.commit('clearNotifications')
store.commit('resetStatuses')
})
diff --git a/src/services/backend_interactor_service/backend_interactor_service.js b/src/services/backend_interactor_service/backend_interactor_service.js
@@ -1,6 +1,7 @@
import apiService from '../api/api.service.js'
import timelineFetcherService from '../timeline_fetcher/timeline_fetcher.service.js'
import notificationsFetcher from '../notifications_fetcher/notifications_fetcher.service.js'
+import followRequestFetcher from '../../services/follow_request_fetcher/follow_request_fetcher.service'
const backendInteractorService = credentials => {
const fetchStatus = ({ id }) => {
@@ -63,6 +64,10 @@ const backendInteractorService = credentials => {
return notificationsFetcher.startFetching({ store, credentials })
}
+ const startFetchingFollowRequest = ({ store }) => {
+ return followRequestFetcher.startFetching({ store, credentials })
+ }
+
// eslint-disable-next-line camelcase
const tagUser = ({ screen_name }, tag) => {
return apiService.tagUser({ screen_name, tag, credentials })
@@ -111,7 +116,6 @@ const backendInteractorService = credentials => {
const subscribeUser = (id) => apiService.subscribeUser({ credentials, id })
const unsubscribeUser = (id) => apiService.unsubscribeUser({ credentials, id })
const fetchBlocks = () => apiService.fetchBlocks({ credentials })
- const fetchFollowRequests = () => apiService.fetchFollowRequests({ credentials })
const fetchOAuthTokens = () => apiService.fetchOAuthTokens({ credentials })
const revokeOAuthToken = (id) => apiService.revokeOAuthToken({ id, credentials })
const fetchPinnedStatuses = (id) => apiService.fetchPinnedStatuses({ credentials, id })
@@ -168,6 +172,7 @@ const backendInteractorService = credentials => {
verifyCredentials: apiService.verifyCredentials,
startFetchingTimeline,
startFetchingNotifications,
+ startFetchingFollowRequest,
fetchMutes,
muteUser,
unmuteUser,
@@ -203,7 +208,6 @@ const backendInteractorService = credentials => {
mfaSetupOTP,
mfaConfirmOTP,
mfaDisableOTP,
- fetchFollowRequests,
approveUser,
denyUser,
vote,