From 53f143f232bf297f2d04e158a8ac43bc2562954d Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Wed, 18 Dec 2019 10:25:27 +0100 Subject: [PATCH] remove subscriptions with short channel URLs (#98) * remove subscriptions with short channel URLs * added comments --- src/page/subscriptions/index.js | 2 ++ src/page/subscriptions/view.js | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/page/subscriptions/index.js b/src/page/subscriptions/index.js index 69257a1..09cb831 100644 --- a/src/page/subscriptions/index.js +++ b/src/page/subscriptions/index.js @@ -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)), diff --git a/src/page/subscriptions/view.js b/src/page/subscriptions/view.js index e7f5352..dc8cf23 100644 --- a/src/page/subscriptions/view.js +++ b/src/page/subscriptions/view.js @@ -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,