remove subscriptions with short channel URLs (#98)

* remove subscriptions with short channel URLs
* added comments
This commit is contained in:
Akinwale Ariwodola 2019-12-18 10:25:27 +01:00 committed by GitHub
parent c58aecb35e
commit 53f143f232
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View file

@ -1,5 +1,6 @@
import { connect } from 'react-redux';
import {
doChannelUnsubscribe,
doFetchMySubscriptions,
doSetViewMode,
doFetchRecommendedSubscriptions,
@ -36,6 +37,7 @@ const select = state => ({
});
const perform = dispatch => ({
channelUnsubscribe: subscription => dispatch(doChannelUnsubscribe(subscription)),
doFetchMySubscriptions: () => dispatch(doFetchMySubscriptions()),
doFetchRecommendedSubscriptions: () => dispatch(doFetchRecommendedSubscriptions()),
doSetViewMode: viewMode => dispatch(doSetViewMode(viewMode)),

View file

@ -82,6 +82,8 @@ class SubscriptionsPage extends React.PureComponent {
if (Constants.DRAWER_ROUTE_SUBSCRIPTIONS === currentRoute && currentRoute !== prevRoute) {
this.onComponentFocused();
}
this.unsubscribeShortChannelUrls();
}
handleSortByItemSelected = item => {
@ -109,6 +111,16 @@ class SubscriptionsPage extends React.PureComponent {
return [Constants.ALL_PLACEHOLDER].concat(channelUris);
};
// Added in 0.12.1. Can be dropped on or after 1 Feb 2020.
unsubscribeShortChannelUrls = () => {
// this should only have to happen once
const { subscribedChannels, channelUnsubscribe } = this.props;
const badSubs = subscribedChannels.filter(sub => sub.uri.split('#')[1].length < 5);
if (badSubs.length > 0) {
badSubs.forEach(sub => channelUnsubscribe(sub));
}
};
render() {
const {
suggestedChannels,