fix back navigation and channel name validation

This commit is contained in:
Akinwale Ariwodola 2019-09-25 14:44:33 +01:00
parent f800f22277
commit f2f5cd9ad5
5 changed files with 31 additions and 16 deletions

View file

@ -1,5 +1,5 @@
import React from 'react';
import { CLAIM_VALUES, isURIValid } from 'lbry-redux';
import { CLAIM_VALUES, isNameValid } from 'lbry-redux';
import { ActivityIndicator, Picker, Text, TextInput, TouchableOpacity, View } from 'react-native';
import Button from 'component/button';
import Colors from 'styles/colors';
@ -85,7 +85,7 @@ export default class ChannelSelector extends React.PureComponent {
newChannelName = newChannelName.slice(1);
}
if (newChannelName.trim().length > 0 && !isURIValid(newChannelName)) {
if (newChannelName.trim().length > 0 && !isNameValid(newChannelName)) {
newChannelNameError = 'Your channel name contains invalid characters.';
} else if (this.channelExists(newChannelName)) {
newChannelNameError = 'You have already created a channel with the same name.';
@ -120,7 +120,7 @@ export default class ChannelSelector extends React.PureComponent {
const { balance, createChannel, onChannelChange, notify } = this.props;
const { newChannelBid, newChannelName } = this.state;
if (newChannelName.trim().length === 0 || !isURIValid(newChannelName.substr(1), false)) {
if (newChannelName.trim().length === 0 || !isNameValid(newChannelName.substr(1), false)) {
notify({ message: 'Your channel name contains invalid characters.' });
return;
}

View file

@ -1,5 +1,5 @@
import React from 'react';
import { CLAIM_VALUES, isURIValid, regexInvalidURI } from 'lbry-redux';
import { CLAIM_VALUES, isNameValid, regexInvalidURI } from 'lbry-redux';
import {
ActivityIndicator,
Alert,
@ -336,7 +336,7 @@ export default class ChannelCreator extends React.PureComponent {
newChannelName = newChannelName.slice(1);
}
if (newChannelName.trim().length > 0 && !isURIValid(newChannelName)) {
if (newChannelName.trim().length > 0 && !isNameValid(newChannelName)) {
newChannelNameError = 'Your channel name contains invalid characters.';
} else if (this.channelExists(newChannelName)) {
newChannelNameError = 'You have already created a channel with the same name.';
@ -389,7 +389,7 @@ export default class ChannelCreator extends React.PureComponent {
website,
} = this.state;
if (newChannelName.trim().length === 0 || !isURIValid(newChannelName.substr(1), false)) {
if (newChannelName.trim().length === 0 || !isNameValid(newChannelName.substr(1), false)) {
notify({ message: 'Your channel name contains invalid characters.' });
return;
}

View file

@ -11,6 +11,7 @@ import {
selectSubscriptionClaims,
selectUnreadSubscriptions,
} from 'lbryinc';
import { doPushDrawerStack } from 'redux/actions/drawer';
import { doSetClientSetting, doSetSortByItem, doSetTimeItem } from 'redux/actions/settings';
import { makeSelectClientSetting, selectSortByItem, selectTimeItem } from 'redux/selectors/settings';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
@ -37,6 +38,7 @@ const perform = dispatch => ({
fetchRewardedContent: () => dispatch(doFetchRewardedContent()),
fetchSubscriptions: () => dispatch(doFetchMySubscriptions()),
fileList: () => dispatch(doFileList()),
pushDrawerStack: () => dispatch(doPushDrawerStack(Constants.DRAWER_ROUTE_DISCOVER)),
removeUnreadSubscriptions: () => dispatch(doRemoveUnreadSubscriptions()),
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)),
setSortByItem: item => dispatch(doSetSortByItem(item)),

View file

@ -38,8 +38,6 @@ class DiscoverPage extends React.PureComponent {
};
componentDidMount() {
NativeModules.Firebase.setCurrentScreen('Your tags');
// Track the total time taken if this is the first launch
AsyncStorage.getItem('firstLaunchTime').then(startTime => {
if (startTime !== null && !isNaN(parseInt(startTime, 10))) {
@ -72,8 +70,29 @@ class DiscoverPage extends React.PureComponent {
this.handleSortByItemSelected(sortByItem);
this.showRatingReminder();
this.onComponentFocused();
}
componentWillReceiveProps(nextProps) {
const { currentRoute: prevRoute, followedTags: prevFollowedTags } = this.props;
const { currentRoute, followedTags } = nextProps;
if (Constants.DRAWER_ROUTE_DISCOVER === currentRoute && currentRoute !== prevRoute) {
this.onComponentFocused();
}
if (!_.isEqual(followedTags, prevFollowedTags)) {
this.buildTagCollection(followedTags);
}
}
onComponentFocused = () => {
const { pushDrawerStack } = this.props;
pushDrawerStack();
NativeModules.Firebase.setCurrentScreen('Your tags');
};
handleSortByItemSelected = item => {
const { setSortByItem } = this.props;
setSortByItem(item);
@ -104,14 +123,6 @@ class DiscoverPage extends React.PureComponent {
return null;
};
componentWillReceiveProps(nextProps) {
const { followedTags: prevFollowedTags } = this.props;
const { followedTags } = nextProps;
if (!_.isEqual(followedTags, prevFollowedTags)) {
this.buildTagCollection(followedTags);
}
}
componentDidUpdate(prevProps, prevState) {
const { unreadSubscriptions, enabledChannelNotifications } = this.props;

View file

@ -32,6 +32,8 @@ reducers[Constants.ACTION_PUSH_DRAWER_STACK] = (state, action) => {
newStack.push({ route: routeName, params });
}
console.log(newStack);
return {
...state,
stack: newStack,