#388: get follow request on a real-time basis
This commit is contained in:
parent
058238c3c6
commit
7c6446a9de
|
@ -4,19 +4,10 @@ const FollowRequests = {
|
||||||
components: {
|
components: {
|
||||||
UserCard
|
UserCard
|
||||||
},
|
},
|
||||||
created () {
|
|
||||||
this.updateRequests()
|
|
||||||
},
|
|
||||||
computed: {
|
computed: {
|
||||||
requests () {
|
requests () {
|
||||||
return this.$store.state.api.followRequests
|
return this.$store.state.api.followRequests
|
||||||
}
|
}
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
updateRequests () {
|
|
||||||
this.$store.state.api.backendInteractor.fetchFollowRequests()
|
|
||||||
.then((requests) => { this.$store.commit('setFollowRequests', requests) })
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,23 @@
|
||||||
|
import requestFetcher from '../../services/notifications_fetcher/request_fetcher.service.js'
|
||||||
|
|
||||||
const NavPanel = {
|
const NavPanel = {
|
||||||
|
created () {
|
||||||
|
if (this.currentUser && this.currentUser.locked) {
|
||||||
|
const store = this.$store
|
||||||
|
const credentials = store.state.users.currentUser.credentials
|
||||||
|
|
||||||
|
requestFetcher.startFetching({ store, credentials })
|
||||||
|
}
|
||||||
|
},
|
||||||
computed: {
|
computed: {
|
||||||
currentUser () {
|
currentUser () {
|
||||||
return this.$store.state.users.currentUser
|
return this.$store.state.users.currentUser
|
||||||
},
|
},
|
||||||
chat () {
|
chat () {
|
||||||
return this.$store.state.chat.channel
|
return this.$store.state.chat.channel
|
||||||
|
},
|
||||||
|
followRequestCount () {
|
||||||
|
return this.$store.state.api.followRequests.length
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,8 @@
|
||||||
<li v-if='currentUser && currentUser.locked'>
|
<li v-if='currentUser && currentUser.locked'>
|
||||||
<router-link :to="{ name: 'friend-requests' }">
|
<router-link :to="{ name: 'friend-requests' }">
|
||||||
{{ $t("nav.friend_requests")}}
|
{{ $t("nav.friend_requests")}}
|
||||||
<span v-if='currentUser.follow_request_count > 0' class="badge follow-request-count">
|
<span v-if='followRequestCount > 0' class="badge follow-request-count">
|
||||||
{{currentUser.follow_request_count}}
|
{{followRequestCount}}
|
||||||
</span>
|
</span>
|
||||||
</router-link>
|
</router-link>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import Notification from '../notification/notification.vue'
|
import Notification from '../notification/notification.vue'
|
||||||
import notificationsFetcher from '../../services/notifications_fetcher/notifications_fetcher.service.js'
|
import notificationsFetcher from '../../services/notifications_fetcher/notifications_fetcher.service.js'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
notificationsFromStore,
|
notificationsFromStore,
|
||||||
visibleNotificationsFromStore,
|
visibleNotificationsFromStore,
|
||||||
|
|
|
@ -32,6 +32,9 @@ const SideDrawer = {
|
||||||
},
|
},
|
||||||
sitename () {
|
sitename () {
|
||||||
return this.$store.state.instance.name
|
return this.$store.state.instance.name
|
||||||
|
},
|
||||||
|
followRequestCount () {
|
||||||
|
return this.$store.state.api.followRequests.length
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
|
@ -45,8 +45,8 @@
|
||||||
<li v-if="currentUser && currentUser.locked" @click="toggleDrawer">
|
<li v-if="currentUser && currentUser.locked" @click="toggleDrawer">
|
||||||
<router-link to='/friend-requests'>
|
<router-link to='/friend-requests'>
|
||||||
{{ $t("nav.friend_requests") }}
|
{{ $t("nav.friend_requests") }}
|
||||||
<span v-if='currentUser.follow_request_count > 0' class="badge follow-request-count">
|
<span v-if='followRequestCount > 0' class="badge follow-request-count">
|
||||||
{{currentUser.follow_request_count}}
|
{{followRequestCount}}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
</router-link>
|
</router-link>
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
import apiService from '../api/api.service.js'
|
||||||
|
|
||||||
|
const fetchAndUpdate = ({ store, credentials }) => {
|
||||||
|
return apiService.fetchFollowRequests({ credentials })
|
||||||
|
.then((requests) => {
|
||||||
|
store.commit('setFollowRequests', requests)
|
||||||
|
}, () => {})
|
||||||
|
.catch(() => {})
|
||||||
|
}
|
||||||
|
|
||||||
|
const startFetching = ({credentials, store}) => {
|
||||||
|
fetchAndUpdate({ credentials, store })
|
||||||
|
const boundFetchAndUpdate = () => fetchAndUpdate({ credentials, store })
|
||||||
|
return setInterval(boundFetchAndUpdate, 10000)
|
||||||
|
}
|
||||||
|
|
||||||
|
const requestFetcher = {
|
||||||
|
startFetching
|
||||||
|
}
|
||||||
|
|
||||||
|
export default requestFetcher
|
Loading…
Reference in New Issue