Merge branch '359-delete-data-bug-fix' into 'master'
Resolve "Bug: Settings > Manage your data > Delete app data" Closes #359 See merge request bloodyhealth/drip!224
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
import RNFS from 'react-native-fs'
|
import RNFS from 'react-native-fs'
|
||||||
import { Alert, ToastAndroid } from 'react-native'
|
import { Alert, ToastAndroid } from 'react-native'
|
||||||
|
import PropTypes from 'prop-types'
|
||||||
|
|
||||||
import { clearDb, isDbEmpty } from '../../../db'
|
import { clearDb, isDbEmpty } from '../../../db'
|
||||||
import { hasEncryptionObservable } from '../../../local-storage'
|
import { hasEncryptionObservable } from '../../../local-storage'
|
||||||
@@ -24,6 +25,7 @@ export default class DeleteData extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onAlertConfirmation = () => {
|
onAlertConfirmation = () => {
|
||||||
|
this.props.onStartDeletion()
|
||||||
if (this.state.isPasswordSet) {
|
if (this.state.isPasswordSet) {
|
||||||
this.setState({ isConfirmingWithPassword: true })
|
this.setState({ isConfirmingWithPassword: true })
|
||||||
} else {
|
} else {
|
||||||
@@ -78,8 +80,9 @@ export default class DeleteData extends Component {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { isConfirmingWithPassword } = this.state
|
const { isConfirmingWithPassword } = this.state
|
||||||
|
const { isDeletingData } = this.props
|
||||||
|
|
||||||
if (isConfirmingWithPassword) {
|
if (isConfirmingWithPassword && isDeletingData) {
|
||||||
return (
|
return (
|
||||||
<ConfirmWithPassword
|
<ConfirmWithPassword
|
||||||
onSuccess={this.deleteAppData}
|
onSuccess={this.deleteAppData}
|
||||||
@@ -94,4 +97,9 @@ export default class DeleteData extends Component {
|
|||||||
</SettingsButton>
|
</SettingsButton>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DeleteData.propTypes = {
|
||||||
|
isDeletingData: PropTypes.bool,
|
||||||
|
onStartDeletion: PropTypes.func.isRequired
|
||||||
}
|
}
|
||||||
@@ -13,7 +13,10 @@ export default class DataManagement extends Component {
|
|||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
this.state = { isLoading: false }
|
this.state = {
|
||||||
|
isLoading: false,
|
||||||
|
currentAction: null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
startLoading = () => {
|
startLoading = () => {
|
||||||
@@ -33,7 +36,22 @@ export default class DataManagement extends Component {
|
|||||||
this.endLoading()
|
this.endLoading()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
startExport = () => {
|
||||||
|
this.setCurrentAction('export')
|
||||||
|
openShareDialogAndExport()
|
||||||
|
}
|
||||||
|
|
||||||
|
startImport = () => {
|
||||||
|
this.setCurrentAction('import')
|
||||||
|
openImportDialog(this.startImportFlow)
|
||||||
|
}
|
||||||
|
|
||||||
|
setCurrentAction = (action) => {
|
||||||
|
this.setState({ currentAction: action })
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const { currentAction } = this.state
|
||||||
return (
|
return (
|
||||||
<View flex={1}>
|
<View flex={1}>
|
||||||
{this.state.isLoading && <AppLoadingView />}
|
{this.state.isLoading && <AppLoadingView />}
|
||||||
@@ -42,14 +60,14 @@ export default class DataManagement extends Component {
|
|||||||
<View>
|
<View>
|
||||||
<FramedSegment title={labels.export.button}>
|
<FramedSegment title={labels.export.button}>
|
||||||
<AppText>{labels.export.segmentExplainer}</AppText>
|
<AppText>{labels.export.segmentExplainer}</AppText>
|
||||||
<SettingsButton onPress={openShareDialogAndExport}>
|
<SettingsButton onPress={this.startExport}>
|
||||||
{labels.export.button}
|
{labels.export.button}
|
||||||
</SettingsButton>
|
</SettingsButton>
|
||||||
</FramedSegment>
|
</FramedSegment>
|
||||||
<FramedSegment title={labels.import.button}>
|
<FramedSegment title={labels.import.button}>
|
||||||
<AppText>{labels.import.segmentExplainer}</AppText>
|
<AppText>{labels.import.segmentExplainer}</AppText>
|
||||||
<SettingsButton
|
<SettingsButton
|
||||||
onPress= {() => openImportDialog(this.startImportFlow)}
|
onPress= {this.startImport}
|
||||||
>
|
>
|
||||||
{labels.import.button}
|
{labels.import.button}
|
||||||
</SettingsButton>
|
</SettingsButton>
|
||||||
@@ -59,7 +77,10 @@ export default class DataManagement extends Component {
|
|||||||
last
|
last
|
||||||
>
|
>
|
||||||
<AppText>{labels.deleteSegment.explainer}</AppText>
|
<AppText>{labels.deleteSegment.explainer}</AppText>
|
||||||
<DeleteData />
|
<DeleteData
|
||||||
|
isDeletingData = { currentAction === 'delete' }
|
||||||
|
onStartDeletion = {() => this.setCurrentAction('delete')}
|
||||||
|
/>
|
||||||
</FramedSegment>
|
</FramedSegment>
|
||||||
</View>
|
</View>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
@@ -67,4 +88,4 @@ export default class DataManagement extends Component {
|
|||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user