Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync: ensure qr code and words are shown only when data is fetched #1115

Merged
merged 1 commit into from
Dec 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ export default class AddNewChainCameraOptionModal extends React.PureComponent<Pr
const { fromMobileScreen, onClose, syncData, actions } = this.props
const { useCameraInstead } = this.state

if (!syncData) {
return null
}

return (
<Modal id='addNewChainCameraOptionModal' onClose={onClose} size='small'>
{
Expand All @@ -75,12 +71,18 @@ export default class AddNewChainCameraOptionModal extends React.PureComponent<Pr
</div>
</ModalHeader>
<ModalContent>
<TextAreaClipboard
copiedString={getLocale('copied')}
wordCountString={getLocale('wordCount')}
readOnly={true}
defaultValue={syncData.syncWords}
/>
{
syncData.syncWords
? (
<TextAreaClipboard
copiedString={getLocale('copied')}
wordCountString={getLocale('wordCount')}
readOnly={true}
defaultValue={syncData.syncWords}
/>
)
: null
}
</ModalContent>
<ThreeColumnButtonGrid>
<ThreeColumnButtonGridCol1>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ export default class AddNewChainNoCameraModal extends React.PureComponent<Props,
render () {
const { onClose, syncData } = this.props

if (!syncData) {
return null
}

return (
<Modal id='addNewChainNoCameraModal' onClose={onClose} size='small'>
<ModalHeader>
Expand All @@ -43,12 +39,18 @@ export default class AddNewChainNoCameraModal extends React.PureComponent<Props,
</div>
</ModalHeader>
<ModalContent>
<TextAreaClipboard
copiedString={getLocale('copied')}
wordCountString={getLocale('wordCount')}
readOnly={true}
defaultValue={syncData.syncWords}
/>
{
syncData.syncWords
? (
<TextAreaClipboard
copiedString={getLocale('copied')}
wordCountString={getLocale('wordCount')}
readOnly={true}
defaultValue={syncData.syncWords}
/>
)
: null
}
</ModalContent>
<TwoColumnButtonGrid>
<OneColumnButtonGrid>
Expand Down
4 changes: 0 additions & 4 deletions components/brave_sync/ui/components/modals/deviceType.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@ export default class DeviceTypeModal extends React.PureComponent<Props, State> {
const { actions, syncData } = this.props
const { addNewChainNoCamera, scanCode } = this.state

if (!syncData) {
return null
}

return (
<Modal id='deviceTypeModal' onClose={this.onClickClose} size='small'>
{
Expand Down
10 changes: 5 additions & 5 deletions components/brave_sync/ui/components/modals/scanCode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ export default class ScanCodeModal extends React.PureComponent<Props, State> {
const { onClose, syncData, actions } = this.props
const { enterCodeWordsInstead } = this.state

if (!syncData) {
return null
}

return (
<Modal id='scanCodeModal' onClose={onClose} size='small'>
{
Expand All @@ -71,7 +67,11 @@ export default class ScanCodeModal extends React.PureComponent<Props, State> {
</ModalHeader>
<ScanGrid>
<div><SyncMobilePicture /></div>
<QRCode size='normal' src={syncData.seedQRImageSource} />
{
syncData.seedQRImageSource
? <QRCode size='normal' src={syncData.seedQRImageSource} />
: null
}
</ScanGrid>
<ThreeColumnButtonGrid>
<ThreeColumnButtonGridCol1>
Expand Down
44 changes: 26 additions & 18 deletions components/brave_sync/ui/components/modals/viewSyncCode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,32 +30,40 @@ export default class ViewSyncCodeModal extends React.PureComponent<Props, {}> {
render () {
const { onClose, syncData } = this.props

if (!syncData) {
return null
}

return (
<Modal id='viewSyncCodeModal' onClose={onClose} size='small'>
<ViewSyncCodeGrid>
<div>
<ModalTitle level={3}>{getLocale('wordCode')}</ModalTitle>
<TextAreaClipboard
copiedString={getLocale('copied')}
wordCountString={getLocale('wordCount')}
readOnly={true}
defaultValue={syncData.syncWords}
/>
{
syncData.syncWords
? (
<TextAreaClipboard
copiedString={getLocale('copied')}
wordCountString={getLocale('wordCount')}
readOnly={true}
defaultValue={syncData.syncWords}
/>
)
: null
}
</div>
<div>
<ModalTitle level={3}>{getLocale('qrCode')}</ModalTitle>
<QRCode
size='small'
src={syncData.seedQRImageSource}
style={{
// TODO: @cezaraugusto fix this in brave-ui
border: '1px solid #DFDFE8'
}}
/>
{
syncData.seedQRImageSource
? (
<QRCode
size='small'
src={syncData.seedQRImageSource}
style={{
// TODO: @cezaraugusto fix this in brave-ui
border: '1px solid #DFDFE8'
}}
/>
)
: null
}
</div>
</ViewSyncCodeGrid>
<TwoColumnButtonGrid>
Expand Down