Skip to content

Commit ae00834

Browse files
committed
Persist showing Choose Device Type modal when only 1 device is available
1 parent 37271b6 commit ae00834

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

components/brave_sync/ui/containers/enabledContent.tsx

+24
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,30 @@ export default class SyncEnabledContent extends React.PureComponent<Props, State
7070
}
7171
}
7272

73+
componentDidMount () {
74+
this.shouldShowAddDeviceModal()
75+
}
76+
77+
componentDidUpdate (prevProps: Props) {
78+
if (
79+
prevProps.syncData.devices.length !==
80+
this.props.syncData.devices.length
81+
) {
82+
// if devices length changed, users either added
83+
// or removed a device. again, check if they are less than 2
84+
// so we can remind them again to add a new device
85+
this.shouldShowAddDeviceModal()
86+
}
87+
}
88+
89+
shouldShowAddDeviceModal = () => {
90+
const { syncData } = this.props
91+
const hasLessThanTwoDevices: boolean = syncData.devices.length < 2
92+
// if only one device is found, remind the user
93+
// at every page refresh to add a new device
94+
this.setState({ addDevice: hasLessThanTwoDevices })
95+
}
96+
7397
getDevicesRows = (devices?: any): Row[] | undefined => {
7498
if (!devices) {
7599
return

0 commit comments

Comments
 (0)