1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +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

@ -1,6 +1,7 @@
#!/bin/bash
CLIENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
yarn install
mkdir -p "$CLIENT_DIR/build"
rm -f "$CLIENT_DIR/app/lib"
ln -s "$CLIENT_DIR/../ReactNativeClient/lib" "$CLIENT_DIR/app"

View File

@ -9,4 +9,5 @@ cp "$CLIENT_DIR/../ReactNativeClient/lib/package.json" build/lib
#cp "$CLIENT_DIR/app/main.sh" build/
cd "$CLIENT_DIR/build"
sudo npm install -g --save
#sudo yarn global add
cd -

View File

@ -7,7 +7,7 @@
"url": "https://github.com/laurent22/joplin"
},
"url": "git://github.com/laurent22/joplin.git",
"version": "0.8.44",
"version": "0.8.52",
"bin": {
"joplin": "./main_launcher.js"
},

View File

@ -666,7 +666,7 @@ babel-register@^6.24.1:
mkdirp "^0.5.1"
source-map-support "^0.4.2"
babel-runtime@^6.18.0, babel-runtime@^6.22.0:
babel-runtime@^6.18.0, babel-runtime@^6.22.0, babel-runtime@^6.23.0:
version "6.23.0"
resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.23.0.tgz#0a9489f144de70efb3ce4300accdb329e2fc543b"
dependencies:

View File

@ -90,8 +90,8 @@ android {
applicationId "net.cozic.joplin"
minSdkVersion 16
targetSdkVersion 22
versionCode 18
versionName "0.9.5"
versionCode 20
versionName "0.9.7"
ndk {
abiFilters "armeabi-v7a", "x86"
}

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;

View File

@ -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;

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;

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...');

View File

@ -305,9 +305,9 @@ async function initialize(dispatch, backButtonHandler) {
const dbLogger = new Logger();
dbLogger.addTarget('database', { database: logDatabase, source: 'm' });
if (Setting.value('env') == 'dev') dbLogger.addTarget('console');
if (Setting.value('env') == 'dev') {
dbLogger.setLevel(Logger.LEVEL_INFO); // Set to LEVEL_DEBUG for full SQL queries
dbLogger.addTarget('console');
dbLogger.setLevel(Logger.LEVEL_DEBUG); // Set to LEVEL_DEBUG for full SQL queries
} else {
dbLogger.setLevel(Logger.LEVEL_INFO);
}
@ -381,6 +381,7 @@ class AppComponent extends React.Component {
async componentDidMount() {
await initialize(this.props.dispatch, this.backButtonHandler.bind(this));
reg.scheduleSync();
}
backButtonHandler() {