1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-02 12:47:41 +02:00

refresh notes list on AppState Changes

- remove mistaken console.log calls in root.js
This commit is contained in:
Caleb John 2018-07-20 15:59:55 +02:00
parent 8840631266
commit 3caf398021
2 changed files with 14 additions and 4 deletions

View File

@ -1,5 +1,5 @@
const React = require('react'); const Component = React.Component;
const { View, Button, Text } = require('react-native');
const { AppState, View, Button, Text } = require('react-native');
const { stateUtils } = require('lib/reducer.js');
const { connect } = require('react-redux');
const { reg } = require('lib/registry.js');
@ -26,6 +26,13 @@ class NotesScreenComponent extends BaseScreenComponent {
constructor() {
super();
this.onAppStateChange_ = async () => {
// Force an update to the notes list when app state changes
let newProps = Object.assign({}, this.props);
newProps.notesSource = '';
await this.refreshNotes(newProps);
}
this.sortButton_press = async () => {
const buttons = [];
const sortNoteOptions = Setting.enumOptions('notes.sortOrder.field');
@ -67,6 +74,11 @@ class NotesScreenComponent extends BaseScreenComponent {
async componentDidMount() {
await this.refreshNotes();
AppState.addEventListener('change', this.onAppStateChange_);
}
async componentWillUnmount() {
AppState.removeEventListener('change', this.onAppStateChange_);
}
async UNSAFE_componentWillReceiveProps(newProps) {
@ -233,4 +245,4 @@ const NotesScreen = connect(
}
)(NotesScreenComponent)
module.exports = { NotesScreen };
module.exports = { NotesScreen };

View File

@ -528,8 +528,6 @@ class AppComponent extends React.Component {
const { type, value } = await ShareExtension.data();
if (type != "") {
console.log(value);
console.log(type)
this.props.dispatch({
type: 'NAV_GO',