fix unfollowing unpublished channels (#7737)

This commit is contained in:
jessopb 2022-11-18 10:22:32 -05:00 committed by GitHub
parent f1b1523017
commit 8dd7150d67
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -9,7 +9,7 @@ import {
selectClaimForUri, selectClaimForUri,
} from 'redux/selectors/claims'; } from 'redux/selectors/claims';
import { swapKeyAndValue } from 'util/swap-json'; import { swapKeyAndValue } from 'util/swap-json';
import { getChannelFromClaim } from 'util/claim'; import { getChannelFromClaim, isChannelClaim } from 'util/claim';
// Returns the entire subscriptions state // Returns the entire subscriptions state
const selectState = (state) => state.subscriptions || {}; const selectState = (state) => state.subscriptions || {};
@ -114,12 +114,18 @@ export const makeSelectChannelInSubscriptions = (uri) =>
createSelector(selectSubscriptions, (subscriptions) => subscriptions.some((sub) => sub.uri === uri)); createSelector(selectSubscriptions, (subscriptions) => subscriptions.some((sub) => sub.uri === uri));
export const selectIsSubscribedForUri = createCachedSelector( export const selectIsSubscribedForUri = createCachedSelector(
(state, uri) => uri,
selectClaimForUri, selectClaimForUri,
selectSubscriptions, selectSubscriptions,
(claim, subscriptions) => { (uri, claim, subscriptions) => {
const channelClaim = getChannelFromClaim(claim); const channelClaim = getChannelFromClaim(claim);
if (channelClaim) { if (channelClaim) {
const uri = channelClaim.permanent_url; const permanentUrl = channelClaim.permanent_url;
return subscriptions.some((sub) => isURIEqual(sub.uri, permanentUrl));
}
// If it failed, it could be an abandoned channel. Try parseURI:
if (isChannelClaim(claim, uri)) {
return subscriptions.some((sub) => isURIEqual(sub.uri, uri)); return subscriptions.some((sub) => isURIEqual(sub.uri, uri));
} }
return false; return false;