fix back navigation and channel name validation
This commit is contained in:
parent
f800f22277
commit
f2f5cd9ad5
5 changed files with 31 additions and 16 deletions
|
@ -1,5 +1,5 @@
|
||||||
import React from 'react';
|
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 { ActivityIndicator, Picker, Text, TextInput, TouchableOpacity, View } from 'react-native';
|
||||||
import Button from 'component/button';
|
import Button from 'component/button';
|
||||||
import Colors from 'styles/colors';
|
import Colors from 'styles/colors';
|
||||||
|
@ -85,7 +85,7 @@ export default class ChannelSelector extends React.PureComponent {
|
||||||
newChannelName = newChannelName.slice(1);
|
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.';
|
newChannelNameError = 'Your channel name contains invalid characters.';
|
||||||
} else if (this.channelExists(newChannelName)) {
|
} else if (this.channelExists(newChannelName)) {
|
||||||
newChannelNameError = 'You have already created a channel with the same name.';
|
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 { balance, createChannel, onChannelChange, notify } = this.props;
|
||||||
const { newChannelBid, newChannelName } = this.state;
|
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.' });
|
notify({ message: 'Your channel name contains invalid characters.' });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { CLAIM_VALUES, isURIValid, regexInvalidURI } from 'lbry-redux';
|
import { CLAIM_VALUES, isNameValid, regexInvalidURI } from 'lbry-redux';
|
||||||
import {
|
import {
|
||||||
ActivityIndicator,
|
ActivityIndicator,
|
||||||
Alert,
|
Alert,
|
||||||
|
@ -336,7 +336,7 @@ export default class ChannelCreator extends React.PureComponent {
|
||||||
newChannelName = newChannelName.slice(1);
|
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.';
|
newChannelNameError = 'Your channel name contains invalid characters.';
|
||||||
} else if (this.channelExists(newChannelName)) {
|
} else if (this.channelExists(newChannelName)) {
|
||||||
newChannelNameError = 'You have already created a channel with the same name.';
|
newChannelNameError = 'You have already created a channel with the same name.';
|
||||||
|
@ -389,7 +389,7 @@ export default class ChannelCreator extends React.PureComponent {
|
||||||
website,
|
website,
|
||||||
} = this.state;
|
} = 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.' });
|
notify({ message: 'Your channel name contains invalid characters.' });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import {
|
||||||
selectSubscriptionClaims,
|
selectSubscriptionClaims,
|
||||||
selectUnreadSubscriptions,
|
selectUnreadSubscriptions,
|
||||||
} from 'lbryinc';
|
} from 'lbryinc';
|
||||||
|
import { doPushDrawerStack } from 'redux/actions/drawer';
|
||||||
import { doSetClientSetting, doSetSortByItem, doSetTimeItem } from 'redux/actions/settings';
|
import { doSetClientSetting, doSetSortByItem, doSetTimeItem } from 'redux/actions/settings';
|
||||||
import { makeSelectClientSetting, selectSortByItem, selectTimeItem } from 'redux/selectors/settings';
|
import { makeSelectClientSetting, selectSortByItem, selectTimeItem } from 'redux/selectors/settings';
|
||||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||||
|
@ -37,6 +38,7 @@ const perform = dispatch => ({
|
||||||
fetchRewardedContent: () => dispatch(doFetchRewardedContent()),
|
fetchRewardedContent: () => dispatch(doFetchRewardedContent()),
|
||||||
fetchSubscriptions: () => dispatch(doFetchMySubscriptions()),
|
fetchSubscriptions: () => dispatch(doFetchMySubscriptions()),
|
||||||
fileList: () => dispatch(doFileList()),
|
fileList: () => dispatch(doFileList()),
|
||||||
|
pushDrawerStack: () => dispatch(doPushDrawerStack(Constants.DRAWER_ROUTE_DISCOVER)),
|
||||||
removeUnreadSubscriptions: () => dispatch(doRemoveUnreadSubscriptions()),
|
removeUnreadSubscriptions: () => dispatch(doRemoveUnreadSubscriptions()),
|
||||||
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)),
|
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)),
|
||||||
setSortByItem: item => dispatch(doSetSortByItem(item)),
|
setSortByItem: item => dispatch(doSetSortByItem(item)),
|
||||||
|
|
|
@ -38,8 +38,6 @@ class DiscoverPage extends React.PureComponent {
|
||||||
};
|
};
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
NativeModules.Firebase.setCurrentScreen('Your tags');
|
|
||||||
|
|
||||||
// Track the total time taken if this is the first launch
|
// Track the total time taken if this is the first launch
|
||||||
AsyncStorage.getItem('firstLaunchTime').then(startTime => {
|
AsyncStorage.getItem('firstLaunchTime').then(startTime => {
|
||||||
if (startTime !== null && !isNaN(parseInt(startTime, 10))) {
|
if (startTime !== null && !isNaN(parseInt(startTime, 10))) {
|
||||||
|
@ -72,8 +70,29 @@ class DiscoverPage extends React.PureComponent {
|
||||||
|
|
||||||
this.handleSortByItemSelected(sortByItem);
|
this.handleSortByItemSelected(sortByItem);
|
||||||
this.showRatingReminder();
|
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 => {
|
handleSortByItemSelected = item => {
|
||||||
const { setSortByItem } = this.props;
|
const { setSortByItem } = this.props;
|
||||||
setSortByItem(item);
|
setSortByItem(item);
|
||||||
|
@ -104,14 +123,6 @@ class DiscoverPage extends React.PureComponent {
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
componentWillReceiveProps(nextProps) {
|
|
||||||
const { followedTags: prevFollowedTags } = this.props;
|
|
||||||
const { followedTags } = nextProps;
|
|
||||||
if (!_.isEqual(followedTags, prevFollowedTags)) {
|
|
||||||
this.buildTagCollection(followedTags);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidUpdate(prevProps, prevState) {
|
componentDidUpdate(prevProps, prevState) {
|
||||||
const { unreadSubscriptions, enabledChannelNotifications } = this.props;
|
const { unreadSubscriptions, enabledChannelNotifications } = this.props;
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,8 @@ reducers[Constants.ACTION_PUSH_DRAWER_STACK] = (state, action) => {
|
||||||
newStack.push({ route: routeName, params });
|
newStack.push({ route: routeName, params });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(newStack);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
stack: newStack,
|
stack: newStack,
|
||||||
|
|
Loading…
Add table
Reference in a new issue