Remove pagination support from block-list

This commit is contained in:
taehoon 2019-02-13 21:08:14 -05:00
parent 159e84532e
commit 8c8a6edc78
4 changed files with 14 additions and 17 deletions

View file

@ -7,13 +7,15 @@ import StyleSwitcher from '../style_switcher/style_switcher.vue'
import fileSizeFormatService from '../../services/file_size_format/file_size_format.js' import fileSizeFormatService from '../../services/file_size_format/file_size_format.js'
import BlockCard from '../block_card/block_card.vue' import BlockCard from '../block_card/block_card.vue'
import withLoadMore from '../../hocs/with_load_more/with_load_more' import withLoadMore from '../../hocs/with_load_more/with_load_more'
import withSubscription from '../../hocs/with_subscription/with_subscription'
import withList from '../../hocs/with_list/with_list' import withList from '../../hocs/with_list/with_list'
const BlockList = withList(BlockCard, entry => ({ userId: entry.id })) const BlockList = withList(BlockCard, userId => ({ userId }))
const BlockListWithLoadMore = withLoadMore( const BlockListWithSubscription = withSubscription(
BlockList, BlockList,
(props, $store) => $store.dispatch('fetchBlocks'), (props, $store) => $store.dispatch('fetchBlocks'),
(props, $store) => get($store.state.users.currentUser, 'blocks', []) (props, $store) => get($store.state.users.currentUser, 'blockIds', []),
'entries'
) )
const UserSettings = { const UserSettings = {
@ -53,7 +55,7 @@ const UserSettings = {
StyleSwitcher, StyleSwitcher,
TabSwitcher, TabSwitcher,
ImageCropper, ImageCropper,
'block-list': BlockListWithLoadMore 'block-list': BlockListWithSubscription
}, },
computed: { computed: {
user () { user () {

View file

@ -164,7 +164,7 @@
</div> </div>
<div :label="$t('settings.blocks_tab')"> <div :label="$t('settings.blocks_tab')">
<block-list /> <block-list id="123" />
</div> </div>
</tab-switcher> </tab-switcher>
</div> </div>

View file

@ -1,5 +1,5 @@
import backendInteractorService from '../services/backend_interactor_service/backend_interactor_service.js' import backendInteractorService from '../services/backend_interactor_service/backend_interactor_service.js'
import { compact, map, each, merge, find } from 'lodash' import { compact, map, each, merge, find, union } from 'lodash'
import { set } from 'vue' import { set } from 'vue'
import { registerPushNotifications, unregisterPushNotifications } from '../services/push/push.js' import { registerPushNotifications, unregisterPushNotifications } from '../services/push/push.js'
import oauthApi from '../services/new_api/oauth' import oauthApi from '../services/new_api/oauth'
@ -85,14 +85,9 @@ export const mutations = {
addNewUsers (state, users) { addNewUsers (state, users) {
each(users, (user) => mergeOrAdd(state.users, state.usersObject, user)) each(users, (user) => mergeOrAdd(state.users, state.usersObject, user))
}, },
addBlocks (state, { blocks, page }) { addBlocks (state, blockIds) {
const user = state.currentUser const user = state.currentUser
each(blocks, block => { user.blockIds = union(user.blockIds, blockIds)
if (!find(user.blocks, { id: block.id })) {
user.blocks.push(block)
}
})
user.blocksPage = page + 1
}, },
setUserForStatus (state, status) { setUserForStatus (state, status) {
status.user = state.usersObject[status.user.id] status.user = state.usersObject[status.user.id]
@ -147,10 +142,10 @@ const users = {
.then((user) => store.commit('addNewUsers', [user])) .then((user) => store.commit('addNewUsers', [user]))
}, },
fetchBlocks (store) { fetchBlocks (store) {
const page = store.state.currentUser.blocksPage || 1 return store.rootState.api.backendInteractor.fetchBlocks()
return store.rootState.api.backendInteractor.fetchBlocks({ page })
.then((blocks) => { .then((blocks) => {
store.commit('addBlocks', { blocks, page }) store.commit('addBlocks', map(blocks, 'id'))
store.commit('addNewUsers', blocks)
return blocks return blocks
}) })
}, },

View file

@ -120,7 +120,7 @@ export const parseUser = (data) => {
if (data.pleroma) { if (data.pleroma) {
output.follow_request_count = data.pleroma.follow_request_count output.follow_request_count = data.pleroma.follow_request_count
} }
output.blocks = [] output.blockIds = []
return output return output
} }