Skip to content

Commit

Permalink
Changes in sync UI to allow test of service - subject to be redone
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeyBarabash committed Nov 14, 2019
1 parent 578d968 commit 9cda93a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 21 deletions.
2 changes: 1 addition & 1 deletion components/brave_sync/ui/components/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class SyncPage extends React.PureComponent<Props, {}> {
return (
<div id='syncPage'>
{
syncData.isSyncConfigured && syncData.devices.length > 1
syncData.isSyncConfigured
? <EnabledContent syncData={syncData} actions={actions} />
: <DisabledContent syncData={syncData} actions={actions} />
}
Expand Down
7 changes: 3 additions & 4 deletions components/brave_sync/ui/components/modals/enterSyncCode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ export default class EnterSyncCodeModal extends React.PureComponent<Props, State
(
this.state.willCreateNewSyncChainFromCode &&
prevProps.syncData.isSyncConfigured !==
this.props.syncData.isSyncConfigured &&
this.props.syncData.devices.length > 1
this.props.syncData.isSyncConfigured
)
) {
this.setState({ willCreateNewSyncChainFromCode: false })
Expand Down Expand Up @@ -87,8 +86,8 @@ export default class EnterSyncCodeModal extends React.PureComponent<Props, State
}

onClickConfirmSyncCode = () => {
const { error, thisDeviceName } = this.props.syncData
if (thisDeviceName !== '' || error) {
const { error } = this.props.syncData
if (error) { // Important for the STR
return
}
const { passphrase } = this.state
Expand Down
7 changes: 1 addition & 6 deletions components/brave_sync/ui/components/modals/removeDevice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,7 @@ export default class RemoveMainDeviceModal extends React.PureComponent<Props, St
}

onClickConfirmRemoveDeviceButton = () => {
const { syncData, deviceName, deviceId } = this.props
// if there aren't enough devices, reset sync
if (syncData.devices.length < 2) {
this.props.actions.onSyncReset()
return
}
const { deviceName, deviceId } = this.props
this.props.actions.onRemoveDevice(Number(deviceId), deviceName)
this.setState({ willRemoveDevice: true })
}
Expand Down
9 changes: 4 additions & 5 deletions components/brave_sync/ui/components/modals/scanCode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export default class ScanCodeModal extends React.PureComponent<Props, State> {

componentDidUpdate (prevProps: Readonly<Props>) {
if (
this.props.syncData.devices.length > 1 &&
prevProps.syncData.devices.length !==
this.props.syncData.devices.length
) {
Expand All @@ -78,10 +77,10 @@ export default class ScanCodeModal extends React.PureComponent<Props, State> {
}

onDismissModal = () => {
const { devices, isSyncConfigured } = this.props.syncData
const { isSyncConfigured } = this.props.syncData
// if user is still trying to build a sync chain,
// open the confirmation modal. otherwise close it
isSyncConfigured && devices.length < 2
isSyncConfigured
? this.setState({ willCancelScanCode: true })
: this.dismissAllModals()
}
Expand All @@ -91,12 +90,12 @@ export default class ScanCodeModal extends React.PureComponent<Props, State> {
}

onConfirmDismissModal = () => {
const { devices, isSyncConfigured } = this.props.syncData
const { isSyncConfigured } = this.props.syncData
// sync is enabled when at least 2 devices are in the chain.
// this modal works both with sync enabled and disabled states.
// in case user opens it in the enabled content screen,
// check there are 2 devices in chain before reset
if (isSyncConfigured && devices.length < 2) {
if (isSyncConfigured) {
this.props.actions.onSyncReset()
this.dismissAllModals()
}
Expand Down
9 changes: 4 additions & 5 deletions components/brave_sync/ui/components/modals/viewSyncCode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ export default class ViewSyncCodeModal extends React.PureComponent<Props, State>

componentDidUpdate (prevProps: Readonly<Props>) {
if (
this.props.syncData.devices.length > 1 &&
prevProps.syncData.devices.length !==
this.props.syncData.devices.length
) {
Expand All @@ -74,10 +73,10 @@ export default class ViewSyncCodeModal extends React.PureComponent<Props, State>
}

onDismissModal = () => {
const { devices, isSyncConfigured } = this.props.syncData
const { isSyncConfigured } = this.props.syncData
// if user is still trying to build a sync chain,
// open the confirmation modal. otherwise close it
isSyncConfigured && devices.length < 2
isSyncConfigured
? this.setState({ willCancelViewCode: true })
: this.dismissAllModals()
}
Expand All @@ -87,12 +86,12 @@ export default class ViewSyncCodeModal extends React.PureComponent<Props, State>
}

onConfirmDismissModal = () => {
const { devices, isSyncConfigured } = this.props.syncData
const { isSyncConfigured } = this.props.syncData
// sync is enabled when at least 2 devices are in the chain.
// this modal works both with sync enabled and disabled states.
// in case user opens it in the enabled content screen,
// check there are 2 devices in chain before reset
if (isSyncConfigured && devices.length < 2) {
if (isSyncConfigured) {
this.props.actions.onSyncReset()
this.dismissAllModals()
}
Expand Down

0 comments on commit 9cda93a

Please sign in to comment.