Skip to content

Commit

Permalink
Sidebar: do not show deleted channels
Browse files Browse the repository at this point in the history
  • Loading branch information
infinite-persistence committed Oct 7, 2023
1 parent 3b4aa9b commit 19f22b9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
13 changes: 12 additions & 1 deletion ui/component/sideNavigation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { selectUserVerifiedEmail, selectUser } from 'redux/selectors/user';
import { selectClientSettings, selectHomepageData } from 'redux/selectors/settings';
import { doOpenModal, doSignOut } from 'redux/actions/app';
import { selectUnseenNotificationCount } from 'redux/selectors/notifications';
import { selectClaimsByUri, selectPurchaseUriSuccess } from 'redux/selectors/claims';
import { selectClaimsByUri, selectPurchaseUriSuccess, selectResolvingUris } from 'redux/selectors/claims';
import { selectUserHasValidOdyseeMembership } from 'redux/selectors/memberships';
import { GetLinksData } from 'util/buildHomepage';

Expand Down Expand Up @@ -60,6 +60,8 @@ const selectSidebarCategories = createSelector(

function doGetDisplayedSubs(filter) {
return async (dispatch, getState) => {
await waitIfResolving(1000, 5, getState);

const state = getState();
const claimsByUri = selectClaimsByUri(state);
const subs = selectSubscriptions(state);
Expand All @@ -79,13 +81,22 @@ function doGetDisplayedSubs(filter) {
});
} else {
filteredSubs = lastActiveSubs?.length > 0 ? lastActiveSubs : subs.slice(0, SIDEBAR_SUBS_DISPLAYED);
filteredSubs = filteredSubs.filter((sub) => claimsByUri[sub?.uri]);
}
}

return filteredSubs;
};
}

async function waitIfResolving(waitMs, maxAttempts, getState) {
let isResolvingUris = selectResolvingUris(getState()).length > 0;
for (let waitCount = 0; isResolvingUris && waitCount < maxAttempts; ++waitCount) {
await new Promise((resolve) => setTimeout(resolve, waitMs));
isResolvingUris = selectResolvingUris(getState()).length > 0;
}
}

// ****************************************************************************
// SideNavigation
// ****************************************************************************
Expand Down
1 change: 1 addition & 0 deletions ui/component/sideNavigation/view.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@ function SideNavigation(props: Props) {

React.useEffect(() => {
if (showSubsSection) {
// Done this way to avoid over-render from claimsByUris[].
doGetDisplayedSubs(subscriptionFilter).then((result) => setDisplayedSubs(result));
}
}, [subscriptionFilter, showSubsSection, doGetDisplayedSubs]);
Expand Down

0 comments on commit 19f22b9

Please sign in to comment.