优化写日记页面退出时提示

This commit is contained in:
mx1700 2019-08-04 21:22:22 +08:00
parent 9dd231c41a
commit ab77145596

View file

@ -81,13 +81,13 @@ export default class WritePage extends Component {
navigationButtonPressed({buttonId}) { navigationButtonPressed({buttonId}) {
if(buttonId == 'cancel') { if(buttonId == 'cancel') {
if(this.state.content.length > 0) { if(!(this.state.content.length === 0 || (this.diary && this.diary.content === this.state.content))) {
Alert.alert('提示', '日记还没保存,退出将删除日记内容', [ Alert.alert('提示', '你编辑的日记尚未保存,离开会使内容丢失', [
{ {
text: '取消', onPress: () => {} text: '取消', onPress: () => {}
}, },
{ {
text: '删除并退出', onPress: () => { text: '确定离开', onPress: () => {
this.closePage(); this.closePage();
} }
} }