Skip to content

Commit add9449

Browse files
committed
sync: ensure qr code and words are shown only when data is fetched
fix brave/brave-browser#2604 fix brave/brave-browser#2602
1 parent 54faec8 commit add9449

File tree

5 files changed

+55
-47
lines changed

5 files changed

+55
-47
lines changed

components/brave_sync/ui/components/modals/addNewChainCameraOption.tsx

+12-10
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,6 @@ export default class AddNewChainCameraOptionModal extends React.PureComponent<Pr
5151
const { fromMobileScreen, onClose, syncData, actions } = this.props
5252
const { useCameraInstead } = this.state
5353

54-
if (!syncData) {
55-
return null
56-
}
57-
5854
return (
5955
<Modal id='addNewChainCameraOptionModal' onClose={onClose} size='small'>
6056
{
@@ -75,12 +71,18 @@ export default class AddNewChainCameraOptionModal extends React.PureComponent<Pr
7571
</div>
7672
</ModalHeader>
7773
<ModalContent>
78-
<TextAreaClipboard
79-
copiedString={getLocale('copied')}
80-
wordCountString={getLocale('wordCount')}
81-
readOnly={true}
82-
defaultValue={syncData.syncWords}
83-
/>
74+
{
75+
syncData.syncWords
76+
? (
77+
<TextAreaClipboard
78+
copiedString={getLocale('copied')}
79+
wordCountString={getLocale('wordCount')}
80+
readOnly={true}
81+
defaultValue={syncData.syncWords}
82+
/>
83+
)
84+
: null
85+
}
8486
</ModalContent>
8587
<ThreeColumnButtonGrid>
8688
<ThreeColumnButtonGridCol1>

components/brave_sync/ui/components/modals/addNewChainNoCamera.tsx

+12-10
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ export default class AddNewChainNoCameraModal extends React.PureComponent<Props,
3030
render () {
3131
const { onClose, syncData } = this.props
3232

33-
if (!syncData) {
34-
return null
35-
}
36-
3733
return (
3834
<Modal id='addNewChainNoCameraModal' onClose={onClose} size='small'>
3935
<ModalHeader>
@@ -43,12 +39,18 @@ export default class AddNewChainNoCameraModal extends React.PureComponent<Props,
4339
</div>
4440
</ModalHeader>
4541
<ModalContent>
46-
<TextAreaClipboard
47-
copiedString={getLocale('copied')}
48-
wordCountString={getLocale('wordCount')}
49-
readOnly={true}
50-
defaultValue={syncData.syncWords}
51-
/>
42+
{
43+
syncData.syncWords
44+
? (
45+
<TextAreaClipboard
46+
copiedString={getLocale('copied')}
47+
wordCountString={getLocale('wordCount')}
48+
readOnly={true}
49+
defaultValue={syncData.syncWords}
50+
/>
51+
)
52+
: null
53+
}
5254
</ModalContent>
5355
<TwoColumnButtonGrid>
5456
<OneColumnButtonGrid>

components/brave_sync/ui/components/modals/deviceType.tsx

-4
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,6 @@ export default class DeviceTypeModal extends React.PureComponent<Props, State> {
8787
const { actions, syncData } = this.props
8888
const { addNewChainNoCamera, scanCode } = this.state
8989

90-
if (!syncData) {
91-
return null
92-
}
93-
9490
return (
9591
<Modal id='deviceTypeModal' onClose={this.onClickClose} size='small'>
9692
{

components/brave_sync/ui/components/modals/scanCode.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@ export default class ScanCodeModal extends React.PureComponent<Props, State> {
5252
const { onClose, syncData, actions } = this.props
5353
const { enterCodeWordsInstead } = this.state
5454

55-
if (!syncData) {
56-
return null
57-
}
58-
5955
return (
6056
<Modal id='scanCodeModal' onClose={onClose} size='small'>
6157
{
@@ -71,7 +67,11 @@ export default class ScanCodeModal extends React.PureComponent<Props, State> {
7167
</ModalHeader>
7268
<ScanGrid>
7369
<div><SyncMobilePicture /></div>
74-
<QRCode size='normal' src={syncData.seedQRImageSource} />
70+
{
71+
syncData.seedQRImageSource
72+
? <QRCode size='normal' src={syncData.seedQRImageSource} />
73+
: null
74+
}
7575
</ScanGrid>
7676
<ThreeColumnButtonGrid>
7777
<ThreeColumnButtonGridCol1>

components/brave_sync/ui/components/modals/viewSyncCode.tsx

+26-18
Original file line numberDiff line numberDiff line change
@@ -30,32 +30,40 @@ export default class ViewSyncCodeModal extends React.PureComponent<Props, {}> {
3030
render () {
3131
const { onClose, syncData } = this.props
3232

33-
if (!syncData) {
34-
return null
35-
}
36-
3733
return (
3834
<Modal id='viewSyncCodeModal' onClose={onClose} size='small'>
3935
<ViewSyncCodeGrid>
4036
<div>
4137
<ModalTitle level={3}>{getLocale('wordCode')}</ModalTitle>
42-
<TextAreaClipboard
43-
copiedString={getLocale('copied')}
44-
wordCountString={getLocale('wordCount')}
45-
readOnly={true}
46-
defaultValue={syncData.syncWords}
47-
/>
38+
{
39+
syncData.syncWords
40+
? (
41+
<TextAreaClipboard
42+
copiedString={getLocale('copied')}
43+
wordCountString={getLocale('wordCount')}
44+
readOnly={true}
45+
defaultValue={syncData.syncWords}
46+
/>
47+
)
48+
: null
49+
}
4850
</div>
4951
<div>
5052
<ModalTitle level={3}>{getLocale('qrCode')}</ModalTitle>
51-
<QRCode
52-
size='small'
53-
src={syncData.seedQRImageSource}
54-
style={{
55-
// TODO: @cezaraugusto fix this in brave-ui
56-
border: '1px solid #DFDFE8'
57-
}}
58-
/>
53+
{
54+
syncData.seedQRImageSource
55+
? (
56+
<QRCode
57+
size='small'
58+
src={syncData.seedQRImageSource}
59+
style={{
60+
// TODO: @cezaraugusto fix this in brave-ui
61+
border: '1px solid #DFDFE8'
62+
}}
63+
/>
64+
)
65+
: null
66+
}
5967
</div>
6068
</ViewSyncCodeGrid>
6169
<TwoColumnButtonGrid>

0 commit comments

Comments
 (0)