From 18b7117765735d1c674c892b873c2e03a463253b Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Wed, 11 Dec 2019 09:04:19 +0100 Subject: [PATCH] make channel sort by selection component-specific --- src/page/channel/view.js | 22 +++++++++++----------- src/page/file/view.js | 2 +- src/page/subscriptions/view.js | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/page/channel/view.js b/src/page/channel/view.js index 1363a24..3f15e5f 100644 --- a/src/page/channel/view.js +++ b/src/page/channel/view.js @@ -38,6 +38,7 @@ class ChannelPage extends React.PureComponent { showTimePicker: false, orderBy: ['release_time'], // sort by new by default activeTab: Constants.CONTENT_TAB, + currentSortByItem: Constants.CLAIM_SEARCH_SORT_BY_ITEMS[1], // should always default to sorting channel pages by new }; componentWillMount() { @@ -48,16 +49,14 @@ class ChannelPage extends React.PureComponent { } componentDidMount() { - const { fetchChannelListMine, setSortByItem } = this.props; + const { fetchChannelListMine } = this.props; NativeModules.Firebase.setCurrentScreen('Channel'); - setSortByItem(Constants.CLAIM_SEARCH_SORT_BY_ITEMS[1]); // sort by newest first fetchChannelListMine(); } handleSortByItemSelected = item => { - const { setSortByItem } = this.props; - setSortByItem(item); - this.setState({ orderBy: getOrderBy(item), showSortPicker: false }); + // sort by specific only to this component state + this.setState({ currentSortByItem: item, orderBy: getOrderBy(item), showSortPicker: false }); }; handleTimeItemSelected = item => { @@ -67,17 +66,18 @@ class ChannelPage extends React.PureComponent { }; listHeader = () => { - const { sortByItem, timeItem } = this.props; + const { timeItem } = this.props; + const { currentSortByItem } = this.state; return ( this.setState({ showSortPicker: true })}> - {__(sortByItem.label.split(' ')[0])} + {__(currentSortByItem.label.split(' ')[0])} - {Constants.SORT_BY_TOP === sortByItem.name && ( + {Constants.SORT_BY_TOP === currentSortByItem.name && ( this.setState({ showTimePicker: true })}> {__(timeItem.label)} @@ -207,9 +207,9 @@ class ChannelPage extends React.PureComponent { }; render() { - const { channels, claim, navigation, uri, drawerStack, popDrawerStack, sortByItem, timeItem } = this.props; + const { channels, claim, navigation, uri, drawerStack, popDrawerStack, timeItem } = this.props; const { name, permanent_url: permanentUrl } = claim; - const { autoStyle, showSortPicker, showTimePicker } = this.state; + const { autoStyle, currentSortByItem, showSortPicker, showTimePicker } = this.state; const ownedChannel = channels ? channels.map(channel => channel.permanent_url).includes(permanentUrl) : false; let thumbnailUrl, @@ -327,7 +327,7 @@ class ChannelPage extends React.PureComponent { title={__('Sort content by')} onOverlayPress={() => this.setState({ showSortPicker: false })} onItemSelected={this.handleSortByItemSelected} - selectedItem={sortByItem} + selectedItem={currentSortByItem} items={Constants.CLAIM_SEARCH_SORT_BY_ITEMS} /> )} diff --git a/src/page/file/view.js b/src/page/file/view.js index 31af1af..b7a5381 100644 --- a/src/page/file/view.js +++ b/src/page/file/view.js @@ -1023,7 +1023,7 @@ class FilePage extends React.PureComponent { {__('Tip')} - {!canEdit && ( + {!canEdit && !isPlayable && ( {!fileInfo || (fileInfo.written_bytes <= 0 && !completed && ( diff --git a/src/page/subscriptions/view.js b/src/page/subscriptions/view.js index 97de6f9..e7f5352 100644 --- a/src/page/subscriptions/view.js +++ b/src/page/subscriptions/view.js @@ -243,7 +243,7 @@ class SubscriptionsPage extends React.PureComponent { title={__('Sort content by')} onOverlayPress={() => this.setState({ showSortPicker: false })} onItemSelected={this.handleSortByItemSelected} - selectedItem={this.state.currentSortByItem} + selectedItem={currentSortByItem} items={Constants.CLAIM_SEARCH_SORT_BY_ITEMS} /> )}