2018-03-16 16:18:40 +00:00
|
|
|
<DynamicPageBanner title="Follow requests" icon="#fa-user-plus" />
|
2019-02-16 08:48:45 +00:00
|
|
|
{#if $isUserLoggedIn }
|
|
|
|
<AccountsListPage {accountsFetcher} {accountActions} />
|
|
|
|
{/if}
|
2018-03-16 16:18:40 +00:00
|
|
|
<script>
|
2018-12-11 15:31:48 +00:00
|
|
|
import AccountsListPage from '../_components/AccountsListPage.html'
|
|
|
|
import { store } from '../_store/store'
|
2019-09-17 05:36:24 +00:00
|
|
|
import { getFollowRequests } from '../_api/followRequests'
|
2018-12-11 15:31:48 +00:00
|
|
|
import DynamicPageBanner from '../_components/DynamicPageBanner.html'
|
2018-04-28 21:19:39 +00:00
|
|
|
import { setFollowRequestApprovedOrRejected } from '../_actions/requests'
|
2019-09-17 05:36:24 +00:00
|
|
|
import { database } from '../_database/database'
|
|
|
|
|
|
|
|
// sneakily update the follow reqs count in the cache, since we just fetched it
|
|
|
|
function updateFollowReqsCount ($currentInstance, followReqs) {
|
|
|
|
/* no await */ database.setFollowRequestCount($currentInstance, followReqs.length)
|
|
|
|
const { followRequestCounts } = store.get()
|
|
|
|
followRequestCounts[$currentInstance] = followReqs.length
|
|
|
|
store.set({ followRequestCounts })
|
|
|
|
}
|
2018-03-16 16:18:40 +00:00
|
|
|
|
|
|
|
export default {
|
2018-04-28 21:19:39 +00:00
|
|
|
data: () => ({
|
|
|
|
accountActions: [
|
|
|
|
{
|
|
|
|
icon: '#fa-check',
|
|
|
|
label: 'Approve',
|
|
|
|
onclick: (accountId) => setFollowRequestApprovedOrRejected(accountId, true, true)
|
|
|
|
},
|
|
|
|
{
|
|
|
|
icon: '#fa-times',
|
|
|
|
label: 'Reject',
|
|
|
|
onclick: (accountId) => setFollowRequestApprovedOrRejected(accountId, false, true)
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}),
|
2018-03-16 16:18:40 +00:00
|
|
|
computed: {
|
2019-09-17 05:36:24 +00:00
|
|
|
accountsFetcher: ({ $currentInstance, $accessToken }) => async () => {
|
|
|
|
const followReqs = await getFollowRequests($currentInstance, $accessToken)
|
|
|
|
updateFollowReqsCount($currentInstance, followReqs)
|
|
|
|
return followReqs
|
|
|
|
}
|
2018-03-16 16:18:40 +00:00
|
|
|
},
|
|
|
|
store: () => store,
|
|
|
|
components: {
|
|
|
|
AccountsListPage,
|
|
|
|
DynamicPageBanner
|
|
|
|
}
|
|
|
|
}
|
2018-12-11 15:31:48 +00:00
|
|
|
</script>
|