From 56966ffa31fe0a23c24f2ad83166feeb2e362324 Mon Sep 17 00:00:00 2001 From: infinite-persistence Date: Tue, 22 Mar 2022 13:48:16 +0800 Subject: [PATCH] Fix sidebar active subs not batch-resolving `Lbry.claim_search` was used, so it doesn't save the resolved results to redux. Use `doClaimSearch`. --- ui/redux/actions/subscriptions.js | 10 ++++++---- ui/redux/reducers/subscriptions.js | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/ui/redux/actions/subscriptions.js b/ui/redux/actions/subscriptions.js index 4da356ed2..a31b270e7 100644 --- a/ui/redux/actions/subscriptions.js +++ b/ui/redux/actions/subscriptions.js @@ -1,9 +1,9 @@ // @flow -import Lbry from 'lbry'; import * as ACTIONS from 'constants/action_types'; import { SIDEBAR_SUBS_DISPLAYED } from 'constants/subscriptions'; import REWARDS from 'rewards'; import { Lbryio } from 'lbryinc'; +import { doClaimSearch } from 'redux/actions/claims'; import { doClaimRewardType } from 'redux/actions/rewards'; import { getChannelFromClaim } from 'util/claim'; import { parseURI } from 'util/lbryURI'; @@ -128,11 +128,13 @@ export function doFetchLastActiveSubs(forceFetch: boolean = false, count: number order_by: ['release_time'], }; - Lbry.claim_search(searchOptions) - .then((result) => { + dispatch(doClaimSearch(searchOptions)) + .then((results) => { + const values = Object.values(results || {}); dispatch({ type: ACTIONS.FETCH_LAST_ACTIVE_SUBS_DONE, - data: result.items.map((claim) => getChannelFromClaim(claim)), + // $FlowFixMe https://github.com/facebook/flow/issues/2221 + data: values.map((v) => getChannelFromClaim(v.stream)), }); }) .catch(() => { diff --git a/ui/redux/reducers/subscriptions.js b/ui/redux/reducers/subscriptions.js index 0911b7de8..5cb29ea43 100644 --- a/ui/redux/reducers/subscriptions.js +++ b/ui/redux/reducers/subscriptions.js @@ -82,7 +82,7 @@ export default handleActions( if (activeChannelClaims && activeChannelClaims.length > 0) { const subs = []; activeChannelClaims.forEach((claim) => { - const index = state.subscriptions.findIndex((sub) => isURIEqual(sub.uri, claim.permanent_url)); + const index = state.subscriptions.findIndex((sub) => isURIEqual(sub.uri, claim?.permanent_url)); if (index !== -1) { subs.push(state.subscriptions[index]); }