Publish: Make 'Channel' setting persistent.
Per discussion with Tom.
This commit is contained in:
parent
9d6af38a21
commit
ff7b4092c9
2 changed files with 21 additions and 2 deletions
|
@ -66,6 +66,7 @@ type Props = {
|
|||
// Add back type
|
||||
updatePublishForm: any => void,
|
||||
checkAvailability: string => void,
|
||||
onChannelChange: string => void,
|
||||
};
|
||||
|
||||
function PublishForm(props: Props) {
|
||||
|
@ -89,6 +90,7 @@ function PublishForm(props: Props) {
|
|||
publish,
|
||||
disabled = false,
|
||||
checkAvailability,
|
||||
onChannelChange,
|
||||
} = props;
|
||||
const TAGS_LIMIT = 5;
|
||||
const formDisabled = (!filePath && !editingURI) || publishing;
|
||||
|
@ -144,6 +146,11 @@ function PublishForm(props: Props) {
|
|||
}
|
||||
}, [name, channel, resolveUri, updatePublishForm, checkAvailability]);
|
||||
|
||||
function handleChannelNameChange(channel) {
|
||||
onChannelChange(channel);
|
||||
updatePublishForm({ channel });
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="card-stack">
|
||||
<PublishFile disabled={disabled || publishing} inProgress={isInProgress} />
|
||||
|
@ -182,7 +189,7 @@ function PublishForm(props: Props) {
|
|||
<Card
|
||||
actions={
|
||||
<React.Fragment>
|
||||
<SelectChannel channel={channel} onChannelChange={channel => updatePublishForm({ channel })} />
|
||||
<SelectChannel channel={channel} onChannelChange={handleChannelNameChange} />
|
||||
<p className="help">
|
||||
{__('This is a username or handle that your content can be found under.')}{' '}
|
||||
{__('Ex. @Marvel, @TheBeatles, @BooksByJoe')}
|
||||
|
|
|
@ -5,6 +5,7 @@ import Page from 'component/page';
|
|||
import Yrbl from 'component/yrbl';
|
||||
import LbcSymbol from 'component/common/lbc-symbol';
|
||||
import RewardAuthIntro from 'component/rewardAuthIntro';
|
||||
import usePersistedState from 'effects/use-persisted-state';
|
||||
|
||||
type Props = {
|
||||
balance: number,
|
||||
|
@ -14,6 +15,8 @@ type Props = {
|
|||
function PublishPage(props: Props) {
|
||||
const { balance } = props;
|
||||
|
||||
const [channel, setChannel] = usePersistedState('publish-channel', '');
|
||||
|
||||
function scrollToTop() {
|
||||
const mainContent = document.querySelector('main');
|
||||
if (mainContent) {
|
||||
|
@ -21,6 +24,10 @@ function PublishPage(props: Props) {
|
|||
}
|
||||
}
|
||||
|
||||
function handleChannelChange(channel) {
|
||||
setChannel(channel);
|
||||
}
|
||||
|
||||
return (
|
||||
<Page>
|
||||
{balance === 0 ? (
|
||||
|
@ -55,7 +62,12 @@ function PublishPage(props: Props) {
|
|||
</div>
|
||||
</Fragment>
|
||||
) : (
|
||||
<PublishForm scrollToTop={scrollToTop} disabled={balance === 0} />
|
||||
<PublishForm
|
||||
scrollToTop={scrollToTop}
|
||||
disabled={balance === 0}
|
||||
channel={channel}
|
||||
onChannelChange={handleChannelChange}
|
||||
/>
|
||||
)}
|
||||
</Page>
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue