Publish UX #44
8 changed files with 67 additions and 26 deletions
|
@ -15,7 +15,7 @@ import {
|
||||||
import { doPushDrawerStack, doPopDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer';
|
import { doPushDrawerStack, doPopDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer';
|
||||||
import { doUpdateChannelFormState, doClearChannelFormState } from 'redux/actions/form';
|
import { doUpdateChannelFormState, doClearChannelFormState } from 'redux/actions/form';
|
||||||
import { selectDrawerStack } from 'redux/selectors/drawer';
|
import { selectDrawerStack } from 'redux/selectors/drawer';
|
||||||
import { selectChannelFormState } from 'redux/selectors/form';
|
import { selectChannelFormState, selectHasChannelFormState } from 'redux/selectors/form';
|
||||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||||
import ChannelCreator from './view';
|
import ChannelCreator from './view';
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@ const select = state => ({
|
||||||
drawerStack: selectDrawerStack(state),
|
drawerStack: selectDrawerStack(state),
|
||||||
fetchingChannels: selectFetchingMyChannels(state),
|
fetchingChannels: selectFetchingMyChannels(state),
|
||||||
balance: selectBalance(state),
|
balance: selectBalance(state),
|
||||||
|
hasFormState: selectHasChannelFormState(state),
|
||||||
updatingChannel: selectUpdatingChannel(state),
|
updatingChannel: selectUpdatingChannel(state),
|
||||||
updateChannelError: selectUpdateChannelError(state),
|
updateChannelError: selectUpdateChannelError(state),
|
||||||
});
|
});
|
||||||
|
|
|
@ -35,7 +35,7 @@ export default class ChannelCreator extends React.PureComponent {
|
||||||
canSave: false,
|
canSave: false,
|
||||||
claimId: null,
|
claimId: null,
|
||||||
currentSelectedValue: Constants.ITEM_ANONYMOUS,
|
currentSelectedValue: Constants.ITEM_ANONYMOUS,
|
||||||
currentPhase: Constants.PHASE_LIST,
|
currentPhase: null,
|
||||||
displayName: null,
|
displayName: null,
|
||||||
channelNameUserEdited: false,
|
channelNameUserEdited: false,
|
||||||
newChannelTitle: '',
|
newChannelTitle: '',
|
||||||
|
@ -148,6 +148,7 @@ export default class ChannelCreator extends React.PureComponent {
|
||||||
navigation,
|
navigation,
|
||||||
pushDrawerStack,
|
pushDrawerStack,
|
||||||
setPlayerVisible,
|
setPlayerVisible,
|
||||||
|
hasFormState,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
NativeModules.Firebase.setCurrentScreen('Channels').then(result => {
|
NativeModules.Firebase.setCurrentScreen('Channels').then(result => {
|
||||||
|
@ -163,17 +164,21 @@ export default class ChannelCreator extends React.PureComponent {
|
||||||
DeviceEventEmitter.addListener('onDocumentPickerFilePicked', this.onFilePicked);
|
DeviceEventEmitter.addListener('onDocumentPickerFilePicked', this.onFilePicked);
|
||||||
DeviceEventEmitter.addListener('onDocumentPickerCanceled', this.onPickerCanceled);
|
DeviceEventEmitter.addListener('onDocumentPickerCanceled', this.onPickerCanceled);
|
||||||
|
|
||||||
|
let isEditMode = false;
|
||||||
if (navigation.state.params) {
|
if (navigation.state.params) {
|
||||||
const { editChannelUrl, displayForm } = navigation.state.params;
|
const { editChannelUrl, displayForm } = navigation.state.params;
|
||||||
if (editChannelUrl) {
|
if (editChannelUrl) {
|
||||||
|
isEditMode = true;
|
||||||
this.setState({ editChannelUrl, currentPhase: Constants.PHASE_CREATE });
|
this.setState({ editChannelUrl, currentPhase: Constants.PHASE_CREATE });
|
||||||
} else if (displayForm) {
|
|
||||||
this.loadPendingFormState();
|
|
||||||
this.setState({ currentPhase: Constants.PHASE_CREATE }, () =>
|
|
||||||
pushDrawerStack(Constants.DRAWER_ROUTE_CHANNEL_CREATOR_FORM)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isEditMode && hasFormState) {
|
||||||
|
this.loadPendingFormState();
|
||||||
|
this.setState({ currentPhase: Constants.PHASE_CREATE });
|
||||||
|
} else {
|
||||||
|
this.setState({ currentPhase: Constants.PHASE_LIST });
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -521,7 +526,6 @@ export default class ChannelCreator extends React.PureComponent {
|
||||||
handleNewChannelPress = () => {
|
handleNewChannelPress = () => {
|
||||||
const { pushDrawerStack } = this.props;
|
const { pushDrawerStack } = this.props;
|
||||||
pushDrawerStack(Constants.DRAWER_ROUTE_CHANNEL_CREATOR_FORM);
|
pushDrawerStack(Constants.DRAWER_ROUTE_CHANNEL_CREATOR_FORM);
|
||||||
this.loadPendingFormState();
|
|
||||||
this.setState({ currentPhase: Constants.PHASE_CREATE });
|
this.setState({ currentPhase: Constants.PHASE_CREATE });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -11,13 +11,14 @@ import {
|
||||||
import { selectDrawerStack } from 'redux/selectors/drawer';
|
import { selectDrawerStack } from 'redux/selectors/drawer';
|
||||||
import { doUpdatePublishFormState, doClearPublishFormState } from 'redux/actions/form';
|
import { doUpdatePublishFormState, doClearPublishFormState } from 'redux/actions/form';
|
||||||
import { doPushDrawerStack, doPopDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer';
|
import { doPushDrawerStack, doPopDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer';
|
||||||
import { selectPublishFormState } from 'redux/selectors/form';
|
import { selectPublishFormState, selectHasPublishFormState } from 'redux/selectors/form';
|
||||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||||
import PublishPage from './view';
|
import PublishPage from './view';
|
||||||
|
|
||||||
const select = state => ({
|
const select = state => ({
|
||||||
balance: selectBalance(state),
|
balance: selectBalance(state),
|
||||||
drawerStack: selectDrawerStack(state),
|
drawerStack: selectDrawerStack(state),
|
||||||
|
hasFormState: selectHasPublishFormState(state),
|
||||||
publishFormState: selectPublishFormState(state),
|
publishFormState: selectPublishFormState(state),
|
||||||
publishFormValues: selectPublishFormValues(state),
|
publishFormValues: selectPublishFormValues(state),
|
||||||
});
|
});
|
||||||
|
|
|
@ -84,6 +84,7 @@ class PublishPage extends React.PureComponent {
|
||||||
titleFocused: false,
|
titleFocused: false,
|
||||||
descriptionFocused: false,
|
descriptionFocused: false,
|
||||||
loadingVideos: false,
|
loadingVideos: false,
|
||||||
|
vanityUrl: null,
|
||||||
|
|
||||||
// gallery videos
|
// gallery videos
|
||||||
videos: null,
|
videos: null,
|
||||||
|
@ -102,7 +103,7 @@ class PublishPage extends React.PureComponent {
|
||||||
currentMedia: null,
|
currentMedia: null,
|
||||||
currentThumbnailUri: null,
|
currentThumbnailUri: null,
|
||||||
updatingThumbnailUri: false,
|
updatingThumbnailUri: false,
|
||||||
currentPhase: Constants.PHASE_SELECTOR,
|
currentPhase: null,
|
||||||
|
|
||||||
// publish
|
// publish
|
||||||
advancedMode: false,
|
advancedMode: false,
|
||||||
|
@ -169,14 +170,13 @@ class PublishPage extends React.PureComponent {
|
||||||
|
|
||||||
loadPendingFormState = () => {
|
loadPendingFormState = () => {
|
||||||
const { publishFormState } = this.props;
|
const { publishFormState } = this.props;
|
||||||
const advancedMode = publishFormState.license;
|
const advancedMode = publishFormState.license !== null;
|
||||||
this.setState({ ...publishFormState, advancedMode });
|
this.setState({ ...publishFormState, advancedMode });
|
||||||
};
|
};
|
||||||
|
|
||||||
onComponentFocused = () => {
|
onComponentFocused = () => {
|
||||||
const { balance, pushDrawerStack, setPlayerVisible, navigation } = this.props;
|
const { balance, hasFormState, pushDrawerStack, setPlayerVisible, navigation } = this.props;
|
||||||
NativeModules.Firebase.setCurrentScreen('Publish').then(result => {
|
NativeModules.Firebase.setCurrentScreen('Publish').then(result => {
|
||||||
console.log(navigation.state.params);
|
|
||||||
pushDrawerStack(Constants.DRAWER_ROUTE_PUBLISH, navigation.state.params ? navigation.state.params : null);
|
pushDrawerStack(Constants.DRAWER_ROUTE_PUBLISH, navigation.state.params ? navigation.state.params : null);
|
||||||
setPlayerVisible();
|
setPlayerVisible();
|
||||||
|
|
||||||
|
@ -193,24 +193,35 @@ class PublishPage extends React.PureComponent {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Check if this is an edit action
|
// Check if this is an edit action
|
||||||
|
let isEditMode = false,
|
||||||
|
vanityUrlSet = false;
|
||||||
if (navigation.state.params) {
|
if (navigation.state.params) {
|
||||||
const { displayForm, editMode, claimToEdit, vanityUrl } = navigation.state.params;
|
const { displayForm, editMode, claimToEdit, vanityUrl } = navigation.state.params;
|
||||||
if (editMode) {
|
if (editMode) {
|
||||||
this.prepareEdit(claimToEdit);
|
this.prepareEdit(claimToEdit);
|
||||||
|
isEditMode = true;
|
||||||
} else if (vanityUrl) {
|
} else if (vanityUrl) {
|
||||||
const { claimName } = parseURI(vanityUrl);
|
const { claimName } = parseURI(vanityUrl);
|
||||||
|
vanityUrlSet = true;
|
||||||
this.setState({
|
this.setState({
|
||||||
name: claimName,
|
name: claimName,
|
||||||
hasEditedContentAddress: true,
|
hasEditedContentAddress: true,
|
||||||
vanityUrlSet: true,
|
vanityUrlSet,
|
||||||
|
vanityUrl: claimName,
|
||||||
});
|
});
|
||||||
} else if (displayForm) {
|
|
||||||
this.loadPendingFormState();
|
|
||||||
this.setState({ currentPhase: Constants.PHASE_DETAILS }, () =>
|
|
||||||
pushDrawerStack(Constants.DRAWER_ROUTE_PUBLISH_FORM)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isEditMode && hasFormState) {
|
||||||
|
this.loadPendingFormState();
|
||||||
|
if (vanityUrlSet) {
|
||||||
|
// replace name with the specified vanity URL if there was one in the pending state
|
||||||
|
this.setState({ name: this.state.vanityUrl });
|
||||||
|
}
|
||||||
|
this.setState({ currentPhase: Constants.PHASE_DETAILS });
|
||||||
|
} else {
|
||||||
|
this.setState({ currentPhase: Constants.PHASE_SELECTOR });
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -429,10 +440,6 @@ class PublishPage extends React.PureComponent {
|
||||||
() => {
|
() => {
|
||||||
this.handleNameChange(this.state.name);
|
this.handleNameChange(this.state.name);
|
||||||
pushDrawerStack(Constants.DRAWER_ROUTE_PUBLISH_FORM);
|
pushDrawerStack(Constants.DRAWER_ROUTE_PUBLISH_FORM);
|
||||||
if (!this.state.editMode) {
|
|
||||||
// overwrite media with previous?
|
|
||||||
this.loadPendingFormState();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -449,6 +456,7 @@ class PublishPage extends React.PureComponent {
|
||||||
publishStarted: false,
|
publishStarted: false,
|
||||||
documentPickerOpen: false,
|
documentPickerOpen: false,
|
||||||
editMode: false,
|
editMode: false,
|
||||||
|
vanityUrl: null,
|
||||||
|
|
||||||
currentMedia: null,
|
currentMedia: null,
|
||||||
currentThumbnailUri: null,
|
currentThumbnailUri: null,
|
||||||
|
|
|
@ -157,6 +157,15 @@ class PublishesPage extends React.PureComponent {
|
||||||
initialNumToRender={8}
|
initialNumToRender={8}
|
||||||
maxToRenderPerBatch={24}
|
maxToRenderPerBatch={24}
|
||||||
removeClippedSubviews
|
removeClippedSubviews
|
||||||
|
ListFooterComponent={
|
||||||
|
<View style={publishStyle.publishesFooter}>
|
||||||
|
<Button
|
||||||
|
style={publishStyle.publishesFooterButton}
|
||||||
|
text={__('Publish something new')}
|
||||||
|
onPress={() => navigation.navigate({ routeName: Constants.DRAWER_ROUTE_PUBLISH })}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
}
|
||||||
renderItem={({ item }) => (
|
renderItem={({ item }) => (
|
||||||
<FileListItem
|
<FileListItem
|
||||||
key={item}
|
key={item}
|
||||||
|
|
|
@ -11,3 +11,13 @@ export const selectChannelFormState = createSelector(
|
||||||
selectState,
|
selectState,
|
||||||
state => state.channelFormValues || {}
|
state => state.channelFormValues || {}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const selectHasPublishFormState = createSelector(
|
||||||
|
selectPublishFormState,
|
||||||
|
values => Object.keys(values).length > 0
|
||||||
|
);
|
||||||
|
|
||||||
|
export const selectHasChannelFormState = createSelector(
|
||||||
|
selectChannelFormState,
|
||||||
|
values => Object.keys(values).length > 0
|
||||||
|
);
|
||||||
|
|
|
@ -129,11 +129,9 @@ const channelCreatorStyle = StyleSheet.create({
|
||||||
},
|
},
|
||||||
scrollContainer: {
|
scrollContainer: {
|
||||||
marginTop: 60,
|
marginTop: 60,
|
||||||
marginLeft: 16,
|
|
||||||
marginRight: 16,
|
|
||||||
},
|
},
|
||||||
scrollPadding: {
|
scrollPadding: {
|
||||||
paddingTop: 16,
|
padding: 16,
|
||||||
},
|
},
|
||||||
channelListItem: {
|
channelListItem: {
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
|
|
|
@ -433,6 +433,16 @@ const publishStyle = StyleSheet.create({
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
color: Colors.DescriptionGrey,
|
color: Colors.DescriptionGrey,
|
||||||
},
|
},
|
||||||
|
publishesFooter: {
|
||||||
|
marginTop: 16,
|
||||||
|
marginLeft: 16,
|
||||||
|
marginRight: 16,
|
||||||
|
},
|
||||||
|
publishesFooterButton: {
|
||||||
|
alignSelf: 'flex-start',
|
||||||
|
backgroundColor: Colors.LbryGreen,
|
||||||
|
marginTop: 16,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export default publishStyle;
|
export default publishStyle;
|
||||||
|
|
Loading…
Reference in a new issue