From 8c8a6edc7800bac854ef23f29aa87f5b932cb415 Mon Sep 17 00:00:00 2001 From: taehoon Date: Wed, 13 Feb 2019 21:08:14 -0500 Subject: [PATCH] Remove pagination support from block-list --- src/components/user_settings/user_settings.js | 10 ++++++---- src/components/user_settings/user_settings.vue | 2 +- src/modules/users.js | 17 ++++++----------- .../entity_normalizer.service.js | 2 +- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js index 621dcd4b..8eade382 100644 --- a/src/components/user_settings/user_settings.js +++ b/src/components/user_settings/user_settings.js @@ -7,13 +7,15 @@ import StyleSwitcher from '../style_switcher/style_switcher.vue' import fileSizeFormatService from '../../services/file_size_format/file_size_format.js' import BlockCard from '../block_card/block_card.vue' 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' -const BlockList = withList(BlockCard, entry => ({ userId: entry.id })) -const BlockListWithLoadMore = withLoadMore( +const BlockList = withList(BlockCard, userId => ({ userId })) +const BlockListWithSubscription = withSubscription( BlockList, (props, $store) => $store.dispatch('fetchBlocks'), - (props, $store) => get($store.state.users.currentUser, 'blocks', []) + (props, $store) => get($store.state.users.currentUser, 'blockIds', []), + 'entries' ) const UserSettings = { @@ -53,7 +55,7 @@ const UserSettings = { StyleSwitcher, TabSwitcher, ImageCropper, - 'block-list': BlockListWithLoadMore + 'block-list': BlockListWithSubscription }, computed: { user () { diff --git a/src/components/user_settings/user_settings.vue b/src/components/user_settings/user_settings.vue index be9f27e7..5cf21815 100644 --- a/src/components/user_settings/user_settings.vue +++ b/src/components/user_settings/user_settings.vue @@ -164,7 +164,7 @@
- +
diff --git a/src/modules/users.js b/src/modules/users.js index ce8af68c..1f03b47e 100644 --- a/src/modules/users.js +++ b/src/modules/users.js @@ -1,5 +1,5 @@ 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 { registerPushNotifications, unregisterPushNotifications } from '../services/push/push.js' import oauthApi from '../services/new_api/oauth' @@ -85,14 +85,9 @@ export const mutations = { addNewUsers (state, users) { each(users, (user) => mergeOrAdd(state.users, state.usersObject, user)) }, - addBlocks (state, { blocks, page }) { + addBlocks (state, blockIds) { const user = state.currentUser - each(blocks, block => { - if (!find(user.blocks, { id: block.id })) { - user.blocks.push(block) - } - }) - user.blocksPage = page + 1 + user.blockIds = union(user.blockIds, blockIds) }, setUserForStatus (state, status) { status.user = state.usersObject[status.user.id] @@ -147,10 +142,10 @@ const users = { .then((user) => store.commit('addNewUsers', [user])) }, fetchBlocks (store) { - const page = store.state.currentUser.blocksPage || 1 - return store.rootState.api.backendInteractor.fetchBlocks({ page }) + return store.rootState.api.backendInteractor.fetchBlocks() .then((blocks) => { - store.commit('addBlocks', { blocks, page }) + store.commit('addBlocks', map(blocks, 'id')) + store.commit('addNewUsers', blocks) return blocks }) }, diff --git a/src/services/entity_normalizer/entity_normalizer.service.js b/src/services/entity_normalizer/entity_normalizer.service.js index 1192b6cc..0e1be61e 100644 --- a/src/services/entity_normalizer/entity_normalizer.service.js +++ b/src/services/entity_normalizer/entity_normalizer.service.js @@ -120,7 +120,7 @@ export const parseUser = (data) => { if (data.pleroma) { output.follow_request_count = data.pleroma.follow_request_count } - output.blocks = [] + output.blockIds = [] return output }