Auto save whenever symptom view updates
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import React, { Component } from 'react'
|
||||
import {
|
||||
BackHandler, View, Alert, TouchableOpacity
|
||||
View, Alert, TouchableOpacity
|
||||
} from 'react-native'
|
||||
import { saveSymptom } from '../../../db'
|
||||
import InfoPopUp from './info-symptom'
|
||||
@@ -13,11 +13,6 @@ import styles, { iconStyles } from '../../../styles'
|
||||
export default class SymptomView extends Component {
|
||||
constructor(props) {
|
||||
super()
|
||||
this.backHandler = BackHandler.addEventListener(
|
||||
'hardwareBackPress',
|
||||
this.handleBackButtonPressOnSymptomView.bind(this)
|
||||
)
|
||||
this.globalBackhandler = props.handleBackButtonPress
|
||||
this.date = props.date
|
||||
this.navigate = props.navigate
|
||||
this.state = {
|
||||
@@ -25,6 +20,11 @@ export default class SymptomView extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
this.autoSave()
|
||||
}
|
||||
|
||||
// TODO where is this needed now?
|
||||
async handleBackButtonPressOnSymptomView() {
|
||||
// every specific symptom view provides their own onBackButtonPress method
|
||||
const stopHere = await this.onBackButtonPress()
|
||||
@@ -39,10 +39,6 @@ export default class SymptomView extends Component {
|
||||
saveSymptom(this.symptomName, this.date)
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this.backHandler.remove()
|
||||
}
|
||||
|
||||
isDeleteIconActive() {
|
||||
const symptomValueHasBeenFilledOut = key => {
|
||||
// the state tracks whether the symptom info should be shown,
|
||||
@@ -63,6 +59,7 @@ export default class SymptomView extends Component {
|
||||
<Header
|
||||
title={headerTitles[this.symptomName].toLowerCase()}
|
||||
date={this.date}
|
||||
// TODO what to put here instead?
|
||||
goBack={this.handleBackButtonPressOnSymptomView.bind(this)}
|
||||
deleteIconActive={this.isDeleteIconActive()}
|
||||
deleteEntry={() => {
|
||||
|
||||
Reference in New Issue
Block a user