1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-12-02 22:49:09 +02:00

Fixed various issue in RN app

This commit is contained in:
Laurent Cozic
2017-07-17 21:22:05 +01:00
parent 58fa4a69b0
commit ca68b85837
10 changed files with 51 additions and 8 deletions

View File

@@ -138,6 +138,8 @@ class NoteScreenComponent extends BaseScreenComponent {
async saveNoteButton_press() {
let note = Object.assign({}, this.state.note);
reg.logger().info('Saving note: ', note);
if (!note.parent_id) {
let folder = await Folder.defaultFolder();
if (!folder) {
@@ -179,15 +181,25 @@ class NoteScreenComponent extends BaseScreenComponent {
}
async toggleIsTodo_onPress() {
let note = await Note.toggleIsTodo(this.state.note.id);
let newState = { note: note };
if (!note.id) newState.lastSavedNote = Object.assign({}, note);
this.setState(newState);
}
showMetadata_onPress() {
this.setState({ showNoteMetadata: !this.state.showNoteMetadata });
this.refreshNoteMetadata(true);
}
menuOptions() {
const note = this.state.note;
return [
{ title: _('Attach file'), onPress: () => { this.attachFile_onPress(); } },
{ title: _('Delete note'), onPress: () => { this.deleteNote_onPress(); } },
{ title: note && !!note.is_todo ? _('Convert to regular note') : _('Convert to todo'), onPress: () => { this.toggleIsTodo_onPress(); } },
{ title: _('Toggle metadata'), onPress: () => { this.showMetadata_onPress(); } },
];
}
@@ -195,6 +207,8 @@ class NoteScreenComponent extends BaseScreenComponent {
async saveOneProperty(name, value) {
let note = Object.assign({}, this.state.note);
reg.logger().info('Saving note property: ', note.id, name, value);
if (note.id) {
let toSave = { id: note.id };
toSave[name] = value;
@@ -328,6 +342,14 @@ class NoteScreenComponent extends BaseScreenComponent {
selectedValue: folder ? folder.id : null,
onValueChange: async (itemValue, itemIndex) => {
let note = Object.assign({}, this.state.note);
// RN bug: https://github.com/facebook/react-native/issues/9220
// The Picker fires the onValueChange when the component is initialized
// so we need to check that it has actually changed.
if (note.parent_id == itemValue) return;
reg.logger().info('Moving note: ' + note.parent_id + ' => ' + itemValue);
if (note.id) await Note.moveToFolder(note.id, itemValue);
note.parent_id = itemValue;