1
0
mirror of https://github.com/laurent22/joplin.git synced 2026-05-22 09:05:38 +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
@@ -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;
@@ -1,3 +1,5 @@
import { Setting } from 'lib/models/setting.js';
class GeolocationReact {
static currentPosition_testResponse() {
@@ -16,6 +18,8 @@ class GeolocationReact {
}
static currentPosition(options = null) {
if (Setting.value('env') == 'dev') return this.currentPosition_testResponse();
if (!options) options = {};
if (!('enableHighAccuracy' in options)) options.enableHighAccuracy = true;
if (!('timeout' in options)) options.timeout = 10000;
+11
View File
@@ -211,6 +211,17 @@ class Note extends BaseItem {
});
}
static async toggleIsTodo(noteId) {
let note = await Note.load(noteId);
const isTodo = !note.is_todo ? 1 : 0;
note.is_todo = isTodo;
if (!note.is_todo) {
note.todo_due = 0;
note.todo_completed = 0;
}
return note;
}
static async duplicate(noteId, options = null) {
const changes = options && options.changes;
+4 -1
View File
@@ -90,7 +90,10 @@ reg.synchronizer = async () => {
}
reg.scheduleSync = async () => {
if (reg.scheduleSyncId_) return;
if (reg.scheduleSyncId_) {
clearTimeout(reg.scheduleSyncId_);
reg.scheduleSyncId_ = null;
}
reg.logger().info('Scheduling sync operation...');