mirror of
https://github.com/laurent22/joplin.git
synced 2024-11-27 08:21:03 +02:00
Various changes
This commit is contained in:
parent
e0664167eb
commit
38c9d49cdb
@ -63,7 +63,7 @@ function randomWord() {
|
|||||||
|
|
||||||
function execCommand(client, command, options = {}) {
|
function execCommand(client, command, options = {}) {
|
||||||
let exePath = 'node ' + joplinAppPath;
|
let exePath = 'node ' + joplinAppPath;
|
||||||
let cmd = exePath + ' --profile ' + client.profileDir + ' ' + command;
|
let cmd = exePath + ' --env dev --profile ' + client.profileDir + ' ' + command;
|
||||||
logger.info(client.id + ': ' + command);
|
logger.info(client.id + ': ' + command);
|
||||||
|
|
||||||
if (options.killAfter) {
|
if (options.killAfter) {
|
||||||
@ -80,7 +80,7 @@ function execCommand(client, command, options = {}) {
|
|||||||
reject(error);
|
reject(error);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
resolve(stdout);
|
resolve(stdout.trim());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -40,6 +40,7 @@ const packageJson = require('./package.json');
|
|||||||
|
|
||||||
let initArgs = {
|
let initArgs = {
|
||||||
profileDir: null,
|
profileDir: null,
|
||||||
|
env: 'prod',
|
||||||
}
|
}
|
||||||
|
|
||||||
const fsDriver = new FsDriverNode();
|
const fsDriver = new FsDriverNode();
|
||||||
@ -821,6 +822,13 @@ async function handleStartFlags(argv) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (arg == '--env') {
|
||||||
|
if (!nextArg) throw new Error(_('Usage: --env <dev|prod>'));
|
||||||
|
initArgs.env = nextArg;
|
||||||
|
argv.splice(0, 2);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (arg == '--redraw-disabled') {
|
if (arg == '--redraw-disabled') {
|
||||||
vorpalUtils.setRedrawEnabled(false);
|
vorpalUtils.setRedrawEnabled(false);
|
||||||
argv.splice(0, 1);
|
argv.splice(0, 1);
|
||||||
@ -913,27 +921,19 @@ async function main() {
|
|||||||
|
|
||||||
let argv = process.argv;
|
let argv = process.argv;
|
||||||
argv = await handleStartFlags(argv);
|
argv = await handleStartFlags(argv);
|
||||||
|
|
||||||
if (argv.length) showPromptString = false;
|
if (argv.length) showPromptString = false;
|
||||||
|
|
||||||
const profileDir = initArgs.profileDir ? initArgs.profileDir : os.homedir() + '/.config/' + Setting.value('appName');
|
const profileDir = initArgs.profileDir ? initArgs.profileDir : os.homedir() + '/.config/' + Setting.value('appName');
|
||||||
const resourceDir = profileDir + '/resources';
|
const resourceDir = profileDir + '/resources';
|
||||||
const tempDir = profileDir + '/tmp';
|
|
||||||
|
|
||||||
|
Setting.setConstant('env', initArgs.env);
|
||||||
Setting.setConstant('profileDir', profileDir);
|
Setting.setConstant('profileDir', profileDir);
|
||||||
Setting.setConstant('resourceDir', resourceDir);
|
Setting.setConstant('resourceDir', resourceDir);
|
||||||
Setting.setConstant('tempDir', tempDir);
|
|
||||||
|
|
||||||
await fs.mkdirp(profileDir, 0o755);
|
await fs.mkdirp(profileDir, 0o755);
|
||||||
await fs.mkdirp(resourceDir, 0o755);
|
await fs.mkdirp(resourceDir, 0o755);
|
||||||
await fs.mkdirp(tempDir, 0o755);
|
|
||||||
|
|
||||||
// let logDatabase = new Database(new DatabaseDriverNode());
|
|
||||||
// await logDatabase.open({ name: profileDir + '/database-log.sqlite' });
|
|
||||||
// await logDatabase.exec(Logger.databaseCreateTableSql());
|
|
||||||
|
|
||||||
logger.addTarget('file', { path: profileDir + '/log.txt' });
|
logger.addTarget('file', { path: profileDir + '/log.txt' });
|
||||||
// logger.addTarget('database', { database: logDatabase, source: 'main' });
|
|
||||||
logger.setLevel(logLevel);
|
logger.setLevel(logLevel);
|
||||||
|
|
||||||
dbLogger.addTarget('file', { path: profileDir + '/log-database.txt' });
|
dbLogger.addTarget('file', { path: profileDir + '/log-database.txt' });
|
||||||
@ -943,6 +943,7 @@ async function main() {
|
|||||||
syncLogger.setLevel(logLevel);
|
syncLogger.setLevel(logLevel);
|
||||||
|
|
||||||
logger.info(sprintf('Starting %s %s...', packageJson.name, packageJson.version));
|
logger.info(sprintf('Starting %s %s...', packageJson.name, packageJson.version));
|
||||||
|
logger.info('Environment: ' + Setting.value('env'));
|
||||||
logger.info('Profile directory: ' + profileDir);
|
logger.info('Profile directory: ' + profileDir);
|
||||||
|
|
||||||
// That's not good, but it's to avoid circular dependency issues
|
// That's not good, but it's to avoid circular dependency issues
|
||||||
@ -969,7 +970,9 @@ async function main() {
|
|||||||
|
|
||||||
// If we still have arguments, pass it to Vorpal and exit
|
// If we still have arguments, pass it to Vorpal and exit
|
||||||
if (argv.length) {
|
if (argv.length) {
|
||||||
vorpal.show();
|
//vorpal.delimiter(' AAAAAAAAAAAAAAAAAAAAA');
|
||||||
|
//console.info(vorpal.ui.inquirer);
|
||||||
|
//vorpal.show();
|
||||||
let cmd = shellArgsToString(argv);
|
let cmd = shellArgsToString(argv);
|
||||||
await vorpal.exec(cmd);
|
await vorpal.exec(cmd);
|
||||||
await vorpal.exec('exit');
|
await vorpal.exec('exit');
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
CLIENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
CLIENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
bash $CLIENT_DIR/build.sh && NODE_PATH="$CLIENT_DIR/build/" node build/main.js --profile ~/Temp/TestNotes2 --stack-trace-enabled --log-level debug --redraw-disabled "$@"
|
bash $CLIENT_DIR/build.sh && NODE_PATH="$CLIENT_DIR/build/" node build/main.js --profile ~/Temp/TestNotes2 --stack-trace-enabled --log-level debug --redraw-disabled --env dev "$@"
|
||||||
#bash $CLIENT_DIR/build.sh && NODE_PATH="$CLIENT_DIR/build/" node build/main.js --profile ~/Temp/TestNotes import-enex --fuzzy-matching /home/laurent/Desktop/afaire.enex afaire
|
#bash $CLIENT_DIR/build.sh && NODE_PATH="$CLIENT_DIR/build/" node build/main.js --profile ~/Temp/TestNotes import-enex --fuzzy-matching /home/laurent/Desktop/afaire.enex afaire
|
||||||
#bash $CLIENT_DIR/build.sh && NODE_PATH="$CLIENT_DIR/build/" node build/main.js --profile ~/Temp/TestNotes import-enex --fuzzy-matching /home/laurent/Desktop/Laurent.enex laurent
|
#bash $CLIENT_DIR/build.sh && NODE_PATH="$CLIENT_DIR/build/" node build/main.js --profile ~/Temp/TestNotes import-enex --fuzzy-matching /home/laurent/Desktop/Laurent.enex laurent
|
1
CliClient/test.txt
Normal file
1
CliClient/test.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
[]
|
BIN
ReactNativeClient/android/Feature1024x500.png
Normal file
BIN
ReactNativeClient/android/Feature1024x500.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 23 KiB |
BIN
ReactNativeClient/android/Icon512x512.png
Normal file
BIN
ReactNativeClient/android/Icon512x512.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
BIN
ReactNativeClient/android/Screenshot1.png
Normal file
BIN
ReactNativeClient/android/Screenshot1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
BIN
ReactNativeClient/android/Screenshot2.png
Normal file
BIN
ReactNativeClient/android/Screenshot2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 25 KiB |
@ -45,12 +45,12 @@ android_library(
|
|||||||
|
|
||||||
android_build_config(
|
android_build_config(
|
||||||
name = "build_config",
|
name = "build_config",
|
||||||
package = "com.awesomeproject",
|
package = "net.cozic.joplin",
|
||||||
)
|
)
|
||||||
|
|
||||||
android_resource(
|
android_resource(
|
||||||
name = "res",
|
name = "res",
|
||||||
package = "com.awesomeproject",
|
package = "net.cozic.joplin",
|
||||||
res = "src/main/res",
|
res = "src/main/res",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ apply from: "../../node_modules/react-native/react.gradle"
|
|||||||
* Upload all the APKs to the Play Store and people will download
|
* Upload all the APKs to the Play Store and people will download
|
||||||
* the correct one based on the CPU architecture of their device.
|
* the correct one based on the CPU architecture of their device.
|
||||||
*/
|
*/
|
||||||
def enableSeparateBuildPerCPUArchitecture = false
|
def enableSeparateBuildPerCPUArchitecture = true
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run Proguard to shrink the Java bytecode in release builds.
|
* Run Proguard to shrink the Java bytecode in release builds.
|
||||||
@ -87,11 +87,11 @@ android {
|
|||||||
buildToolsVersion "23.0.1"
|
buildToolsVersion "23.0.1"
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "com.awesomeproject"
|
applicationId "net.cozic.joplin"
|
||||||
minSdkVersion 16
|
minSdkVersion 16
|
||||||
targetSdkVersion 22
|
targetSdkVersion 22
|
||||||
versionCode 1
|
versionCode 2
|
||||||
versionName "1.0"
|
versionName "0.8.0"
|
||||||
ndk {
|
ndk {
|
||||||
abiFilters "armeabi-v7a", "x86"
|
abiFilters "armeabi-v7a", "x86"
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.awesomeproject"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:versionCode="1"
|
package="net.cozic.joplin"
|
||||||
android:versionName="1.0">
|
android:versionCode="2"
|
||||||
|
android:versionName="0.8.0">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
|
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
|
||||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||||
|
<uses-permission android:name="android.permission.READ_PHONE_STATE" tools:node="remove"/>
|
||||||
|
|
||||||
<uses-sdk
|
<uses-sdk
|
||||||
android:minSdkVersion="16"
|
android:minSdkVersion="16"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package com.awesomeproject;
|
package net.cozic.joplin;
|
||||||
|
|
||||||
import com.facebook.react.ReactActivity;
|
import com.facebook.react.ReactActivity;
|
||||||
|
|
||||||
@ -10,6 +10,6 @@ public class MainActivity extends ReactActivity {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected String getMainComponentName() {
|
protected String getMainComponentName() {
|
||||||
return "AwesomeProject";
|
return "Joplin";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package com.awesomeproject;
|
package net.cozic.joplin;
|
||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
|
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">AwesomeProject</string>
|
<string name="app_name">Joplin</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
rootProject.name = 'AwesomeProject'
|
rootProject.name = 'Joplin'
|
||||||
include ':react-native-fs'
|
include ':react-native-fs'
|
||||||
project(':react-native-fs').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fs/android')
|
project(':react-native-fs').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fs/android')
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"name": "AwesomeProject",
|
"name": "Joplin",
|
||||||
"displayName": "AwesomeProject",
|
"displayName": "Joplin",
|
||||||
"expo": {
|
"expo": {
|
||||||
"name": "AwesomeProject",
|
"name": "Joplin",
|
||||||
"description": "No description",
|
"description": "Joplin for Android",
|
||||||
"slug": "AwesomeProject",
|
"slug": "Joplin",
|
||||||
"privacy": "public",
|
"privacy": "public",
|
||||||
"sdkVersion": "18.0.0",
|
"sdkVersion": "18.0.0",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
|
@ -12,7 +12,7 @@ import {
|
|||||||
View
|
View
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
|
|
||||||
export default class AwesomeProject extends Component {
|
export default class Joplin extends Component {
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
@ -50,4 +50,4 @@ const styles = StyleSheet.create({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
AppRegistry.registerComponent('AwesomeProject', () => AwesomeProject);
|
AppRegistry.registerComponent('Joplin', () => Joplin);
|
||||||
|
@ -94,9 +94,7 @@ ScreenHeaderComponent.defaultProps = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const ScreenHeader = connect(
|
const ScreenHeader = connect(
|
||||||
(state) => {
|
//(state) => {}
|
||||||
return { user: state.user };
|
|
||||||
}
|
|
||||||
)(ScreenHeaderComponent)
|
)(ScreenHeaderComponent)
|
||||||
|
|
||||||
export { ScreenHeader };
|
export { ScreenHeader };
|
@ -1,91 +0,0 @@
|
|||||||
import React, { Component } from 'react';
|
|
||||||
import { View, Button, TextInput, Text } from 'react-native';
|
|
||||||
import { connect } from 'react-redux'
|
|
||||||
import { Log } from 'lib/log.js'
|
|
||||||
import { Setting } from 'lib/models/setting.js';
|
|
||||||
import { ScreenHeader } from 'lib/components/screen-header.js';
|
|
||||||
import { _ } from 'lib/locale.js';
|
|
||||||
|
|
||||||
class LoginScreenComponent extends React.Component {
|
|
||||||
|
|
||||||
static navigationOptions(options) {
|
|
||||||
return { header: null };
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
super();
|
|
||||||
this.state = {
|
|
||||||
email: '',
|
|
||||||
password: '',
|
|
||||||
errorMessage: null,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
componentWillMount() {
|
|
||||||
this.setState({ email: this.props.user.email });
|
|
||||||
}
|
|
||||||
|
|
||||||
email_changeText(text) {
|
|
||||||
this.setState({ email: text });
|
|
||||||
}
|
|
||||||
|
|
||||||
password_changeText(text) {
|
|
||||||
this.setState({ password: text });
|
|
||||||
}
|
|
||||||
|
|
||||||
loginButton_press() {
|
|
||||||
this.setState({ errorMessage: null });
|
|
||||||
|
|
||||||
// return Registry.api().post('sessions', null, {
|
|
||||||
// 'email': this.state.email,
|
|
||||||
// 'password': this.state.password,
|
|
||||||
// 'client_id': Setting.value('clientId'),
|
|
||||||
// }).then((session) => {
|
|
||||||
// Log.info('Got session', session);
|
|
||||||
|
|
||||||
// let user = {
|
|
||||||
// email: this.state.email,
|
|
||||||
// session: session.id,
|
|
||||||
// };
|
|
||||||
// Setting.setObject('user', user);
|
|
||||||
|
|
||||||
// this.props.dispatch({
|
|
||||||
// type: 'USER_SET',
|
|
||||||
// user: user,
|
|
||||||
// });
|
|
||||||
|
|
||||||
// this.props.dispatch({
|
|
||||||
// type: 'Navigation/BACK',
|
|
||||||
// });
|
|
||||||
|
|
||||||
// Registry.api().setSession(session.id);
|
|
||||||
|
|
||||||
// //Registry.synchronizer().start();
|
|
||||||
// }).catch((error) => {
|
|
||||||
// this.setState({ errorMessage: _('Could not login: %s)', error.message) });
|
|
||||||
// });
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
|
||||||
return (
|
|
||||||
<View style={{flex: 1}}>
|
|
||||||
<ScreenHeader navState={this.props.navigation.state} />
|
|
||||||
<TextInput value={this.state.email} onChangeText={(text) => this.email_changeText(text)} keyboardType="email-address" />
|
|
||||||
<TextInput value={this.state.password} onChangeText={(text) => this.password_changeText(text)} secureTextEntry={true} />
|
|
||||||
{ this.state.errorMessage && <Text style={{color:'#ff0000'}}>{this.state.errorMessage}</Text> }
|
|
||||||
<Button title="Login" onPress={() => this.loginButton_press()} />
|
|
||||||
</View>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
const LoginScreen = connect(
|
|
||||||
(state) => {
|
|
||||||
return {
|
|
||||||
user: state.user,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
)(LoginScreenComponent)
|
|
||||||
|
|
||||||
export { LoginScreen };
|
|
@ -48,9 +48,7 @@ class SideMenuContentComponent extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
folder_press(folder) {
|
folder_press(folder) {
|
||||||
this.props.dispatch({
|
this.props.dispatch({ type: 'SIDE_MENU_CLOSE' });
|
||||||
type: 'SIDE_MENU_CLOSE',
|
|
||||||
});
|
|
||||||
|
|
||||||
NotesScreenUtils.openNoteList(folder.id);
|
NotesScreenUtils.openNoteList(folder.id);
|
||||||
}
|
}
|
||||||
@ -64,6 +62,7 @@ class SideMenuContentComponent extends Component {
|
|||||||
line.push(_('Remote items to delete: %d/%d.', report.deleteRemote, report.remotesToDelete));
|
line.push(_('Remote items to delete: %d/%d.', report.deleteRemote, report.remotesToDelete));
|
||||||
line.push(_('Items to download: %d/%d.', report.createLocal + report.updateLocal, report.localsToUdpate));
|
line.push(_('Items to download: %d/%d.', report.createLocal + report.updateLocal, report.localsToUdpate));
|
||||||
line.push(_('Local items to delete: %d/%d.', report.deleteLocal, report.localsToDelete));
|
line.push(_('Local items to delete: %d/%d.', report.deleteLocal, report.localsToDelete));
|
||||||
|
line.push(_('Sync state: %s.', report.state));
|
||||||
this.setState({ syncReportText: line.join("\n") });
|
this.setState({ syncReportText: line.join("\n") });
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -75,6 +74,8 @@ class SideMenuContentComponent extends Component {
|
|||||||
Log.error(error);
|
Log.error(error);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
this.props.dispatch({ type: 'SIDE_MENU_CLOSE' });
|
||||||
|
|
||||||
this.props.dispatch({
|
this.props.dispatch({
|
||||||
type: 'Navigation/NAVIGATE',
|
type: 'Navigation/NAVIGATE',
|
||||||
routeName: 'OneDriveLogin',
|
routeName: 'OneDriveLogin',
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
import { BaseModel } from 'lib/base-model.js';
|
|
||||||
|
|
||||||
class Session extends BaseModel {
|
|
||||||
|
|
||||||
static login(email, password) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
export { Session };
|
|
@ -144,7 +144,6 @@ class Setting extends BaseModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Setting.defaults_ = {
|
Setting.defaults_ = {
|
||||||
'clientId': { value: '', type: 'string', public: false },
|
|
||||||
'activeFolderId': { value: '', type: 'string', public: false },
|
'activeFolderId': { value: '', type: 'string', public: false },
|
||||||
'sync.onedrive.auth': { value: '', type: 'string', public: false },
|
'sync.onedrive.auth': { value: '', type: 'string', public: false },
|
||||||
'sync.local.path': { value: '', type: 'string', public: true },
|
'sync.local.path': { value: '', type: 'string', public: true },
|
||||||
@ -155,12 +154,12 @@ Setting.defaults_ = {
|
|||||||
// Contains constants that are set by the application and
|
// Contains constants that are set by the application and
|
||||||
// cannot be modified by the user:
|
// cannot be modified by the user:
|
||||||
Setting.constants_ = {
|
Setting.constants_ = {
|
||||||
|
'env': 'SET_ME',
|
||||||
'appName': 'joplin',
|
'appName': 'joplin',
|
||||||
'appId': 'SET_ME', // Each app should set this identifier
|
'appId': 'SET_ME', // Each app should set this identifier
|
||||||
'appType': 'SET_ME', // 'cli' or 'mobile'
|
'appType': 'SET_ME', // 'cli' or 'mobile'
|
||||||
'resourceDir': '',
|
'resourceDir': '',
|
||||||
'profileDir': '',
|
'profileDir': '',
|
||||||
'tempDir': '',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export { Setting };
|
export { Setting };
|
@ -160,7 +160,7 @@ class OneDriveApi {
|
|||||||
let errorResponse = await response.json();
|
let errorResponse = await response.json();
|
||||||
let error = this.oneDriveErrorResponseToError(errorResponse);
|
let error = this.oneDriveErrorResponseToError(errorResponse);
|
||||||
|
|
||||||
if (error.code == 'InvalidAuthenticationToken') {
|
if (error.code == 'InvalidAuthenticationToken' || error.code == 'unauthenticated') {
|
||||||
await this.refreshAccessToken();
|
await this.refreshAccessToken();
|
||||||
continue;
|
continue;
|
||||||
} else if (error && ((error.error && error.error.code == 'generalException') || (error.code == 'generalException'))) {
|
} else if (error && ((error.error && error.error.code == 'generalException') || (error.code == 'generalException'))) {
|
||||||
|
23
ReactNativeClient/lib/parameters.js
Normal file
23
ReactNativeClient/lib/parameters.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import { Setting } from 'lib/models/setting.js';
|
||||||
|
|
||||||
|
const parameters_ = {};
|
||||||
|
|
||||||
|
parameters_.dev = {
|
||||||
|
oneDrive: {
|
||||||
|
id: 'cbabb902-d276-4ea4-aa88-062a5889d6dc',
|
||||||
|
secret: 'YSvrgQMqw9NzVqgiLfuEky1',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
parameters_.prod = {
|
||||||
|
oneDrive: {
|
||||||
|
id: 'e09fc0de-c958-424f-83a2-e56a721d331b',
|
||||||
|
secret: 'JA3cwsqSGHFtjMwd5XoF5L5',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
function parameters() {
|
||||||
|
return parameters_[Setting.value('env')];
|
||||||
|
}
|
||||||
|
|
||||||
|
export { parameters }
|
@ -1,6 +1,7 @@
|
|||||||
import { Logger } from 'lib/logger.js';
|
import { Logger } from 'lib/logger.js';
|
||||||
import { Setting } from 'lib/models/setting.js';
|
import { Setting } from 'lib/models/setting.js';
|
||||||
import { OneDriveApi } from 'lib/onedrive-api.js';
|
import { OneDriveApi } from 'lib/onedrive-api.js';
|
||||||
|
import { parameters } from 'lib/parameters.js';
|
||||||
import { FileApi } from 'lib/file-api.js';
|
import { FileApi } from 'lib/file-api.js';
|
||||||
import { Synchronizer } from 'lib/synchronizer.js';
|
import { Synchronizer } from 'lib/synchronizer.js';
|
||||||
import { FileApiDriverOneDrive } from 'lib/file-api-driver-onedrive.js';
|
import { FileApiDriverOneDrive } from 'lib/file-api-driver-onedrive.js';
|
||||||
@ -18,11 +19,9 @@ reg.logger = () => {
|
|||||||
reg.oneDriveApi = () => {
|
reg.oneDriveApi = () => {
|
||||||
if (reg.oneDriveApi_) return reg.oneDriveApi_;
|
if (reg.oneDriveApi_) return reg.oneDriveApi_;
|
||||||
|
|
||||||
const CLIENT_ID = 'e09fc0de-c958-424f-83a2-e56a721d331b';
|
|
||||||
const CLIENT_SECRET = 'JA3cwsqSGHFtjMwd5XoF5L5';
|
|
||||||
const isPublic = Setting.value('appType') != 'cli';
|
const isPublic = Setting.value('appType') != 'cli';
|
||||||
|
|
||||||
reg.oneDriveApi_ = new OneDriveApi(CLIENT_ID, CLIENT_SECRET, isPublic);
|
reg.oneDriveApi_ = new OneDriveApi(parameters().oneDrive.id, parameters().oneDrive.secret, isPublic);
|
||||||
|
|
||||||
reg.oneDriveApi_.on('authRefreshed', (a) => {
|
reg.oneDriveApi_.on('authRefreshed', (a) => {
|
||||||
reg.logger().info('Saving updated OneDrive auth.');
|
reg.logger().info('Saving updated OneDrive auth.');
|
||||||
|
@ -121,6 +121,8 @@ class Synchronizer {
|
|||||||
deleteRemote: 0,
|
deleteRemote: 0,
|
||||||
itemConflict: 0,
|
itemConflict: 0,
|
||||||
noteConflict: 0,
|
noteConflict: 0,
|
||||||
|
|
||||||
|
state: this.state(),
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -369,12 +371,13 @@ class Synchronizer {
|
|||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
options.onProgress(report);
|
|
||||||
|
|
||||||
this.logger().info('Synchronization complete [' + synchronizationId + ']:');
|
this.logger().info('Synchronization complete [' + synchronizationId + ']:');
|
||||||
await this.logSyncSummary(report);
|
await this.logSyncSummary(report);
|
||||||
|
|
||||||
this.state_ = 'idle';
|
this.state_ = 'idle';
|
||||||
|
|
||||||
|
report.state = this.state();
|
||||||
|
options.onProgress(report);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ import { Log } from 'lib/log.js'
|
|||||||
import { Root } from './root.js';
|
import { Root } from './root.js';
|
||||||
|
|
||||||
function main() {
|
function main() {
|
||||||
AppRegistry.registerComponent('AwesomeProject', () => Root);
|
AppRegistry.registerComponent('Joplin', () => Root);
|
||||||
console.ignoredYellowBox = ['Remote debugger'];
|
console.ignoredYellowBox = ['Remote debugger'];
|
||||||
Log.info('START ======================================================================================================');
|
Log.info('START ======================================================================================================');
|
||||||
// Note: The final part of the initialization process is in
|
// Note: The final part of the initialization process is in
|
||||||
|
@ -1,37 +1,37 @@
|
|||||||
{
|
{
|
||||||
"name": "AwesomeProject",
|
"name": "Joplin",
|
||||||
"version": "0.0.1",
|
"description": "Joplin for Android",
|
||||||
|
"license": "MIT",
|
||||||
|
"version": "0.8.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node node_modules/react-native/local-cli/cli.js start",
|
"start": "node node_modules/react-native/local-cli/cli.js start",
|
||||||
"test": "jest"
|
"test": "jest"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"dropbox": "^2.5.4",
|
|
||||||
"form-data": "^2.1.4",
|
"form-data": "^2.1.4",
|
||||||
"moment": "^2.18.1",
|
"moment": "^2.18.1",
|
||||||
"react": "16.0.0-alpha.12",
|
"react": "16.0.0-alpha.12",
|
||||||
"react-native": "0.46.0",
|
"react-native": "0.46.0",
|
||||||
"react-native-action-button": "^2.6.9",
|
"react-native-action-button": "^2.6.9",
|
||||||
"react-native-checkbox": "^1.1.0",
|
|
||||||
"react-native-fetch-blob": "^0.10.6",
|
"react-native-fetch-blob": "^0.10.6",
|
||||||
"react-native-fs": "^2.3.3",
|
"react-native-fs": "^2.3.3",
|
||||||
"react-native-popup-menu": "^0.7.4",
|
"react-native-popup-menu": "^0.7.4",
|
||||||
"react-native-side-menu": "^0.20.1",
|
"react-native-side-menu": "^0.20.1",
|
||||||
"react-native-vector-icons": "^2.0.3",
|
"react-native-vector-icons": "^2.0.3",
|
||||||
"react-navigation": "^1.0.0-beta.9",
|
"react-navigation": "^1.0.0-beta.9",
|
||||||
"uuid": "^3.0.1"
|
"uuid": "^3.0.1",
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"babel-jest": "19.0.0",
|
|
||||||
"babel-preset-react-native": "1.9.1",
|
|
||||||
"jest": "19.0.2",
|
|
||||||
"react-test-renderer": "16.0.0-alpha.6",
|
|
||||||
"redux": "3.6.0",
|
"redux": "3.6.0",
|
||||||
"react-redux": "4.4.8",
|
"react-redux": "4.4.8",
|
||||||
"query-string": "4.3.4",
|
"query-string": "4.3.4",
|
||||||
"react-native-sqlite-storage": "3.3.*"
|
"react-native-sqlite-storage": "3.3.*"
|
||||||
},
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"babel-jest": "19.0.0",
|
||||||
|
"babel-preset-react-native": "1.9.1",
|
||||||
|
"jest": "19.0.2",
|
||||||
|
"react-test-renderer": "16.0.0-alpha.6"
|
||||||
|
},
|
||||||
"jest": {
|
"jest": {
|
||||||
"preset": "react-native"
|
"preset": "react-native"
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,6 @@ import { NotesScreenUtils } from 'lib/components/screens/notes-utils.js'
|
|||||||
import { NoteScreen } from 'lib/components/screens/note.js'
|
import { NoteScreen } from 'lib/components/screens/note.js'
|
||||||
import { FolderScreen } from 'lib/components/screens/folder.js'
|
import { FolderScreen } from 'lib/components/screens/folder.js'
|
||||||
import { FoldersScreen } from 'lib/components/screens/folders.js'
|
import { FoldersScreen } from 'lib/components/screens/folders.js'
|
||||||
import { LoginScreen } from 'lib/components/screens/login.js'
|
|
||||||
import { LogScreen } from 'lib/components/screens/log.js'
|
import { LogScreen } from 'lib/components/screens/log.js'
|
||||||
import { LoadingScreen } from 'lib/components/screens/loading.js'
|
import { LoadingScreen } from 'lib/components/screens/loading.js'
|
||||||
import { OneDriveLoginScreen } from 'lib/components/screens/onedrive-login.js'
|
import { OneDriveLoginScreen } from 'lib/components/screens/onedrive-login.js'
|
||||||
@ -43,7 +42,6 @@ let defaultState = {
|
|||||||
selectedNoteId: null,
|
selectedNoteId: null,
|
||||||
selectedItemType: 'note',
|
selectedItemType: 'note',
|
||||||
selectedFolderId: null,
|
selectedFolderId: null,
|
||||||
user: { email: 'laurent@cozic.net', session: null },
|
|
||||||
showSideMenu: false,
|
showSideMenu: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -100,6 +98,8 @@ const reducer = (state = defaultState, action) => {
|
|||||||
// update it within the note array if it already exists.
|
// update it within the note array if it already exists.
|
||||||
case 'NOTES_UPDATE_ONE':
|
case 'NOTES_UPDATE_ONE':
|
||||||
|
|
||||||
|
if (action.note.parent_id != state.selectedFolderId) break;
|
||||||
|
|
||||||
let newNotes = state.notes.splice(0);
|
let newNotes = state.notes.splice(0);
|
||||||
var found = false;
|
var found = false;
|
||||||
for (let i = 0; i < newNotes.length; i++) {
|
for (let i = 0; i < newNotes.length; i++) {
|
||||||
@ -155,12 +155,6 @@ const reducer = (state = defaultState, action) => {
|
|||||||
newState.folders = newFolders;
|
newState.folders = newFolders;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'USER_SET':
|
|
||||||
|
|
||||||
newState = Object.assign({}, state);
|
|
||||||
newState.user = action.user;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'SIDE_MENU_TOGGLE':
|
case 'SIDE_MENU_TOGGLE':
|
||||||
|
|
||||||
newState = Object.assign({}, state);
|
newState = Object.assign({}, state);
|
||||||
@ -193,7 +187,6 @@ const AppNavigator = StackNavigator({
|
|||||||
Note: { screen: NoteScreen },
|
Note: { screen: NoteScreen },
|
||||||
Folder: { screen: FolderScreen },
|
Folder: { screen: FolderScreen },
|
||||||
Folders: { screen: FoldersScreen },
|
Folders: { screen: FoldersScreen },
|
||||||
Login: { screen: LoginScreen },
|
|
||||||
Loading: { screen: LoadingScreen },
|
Loading: { screen: LoadingScreen },
|
||||||
OneDriveLogin: { screen: OneDriveLoginScreen },
|
OneDriveLogin: { screen: OneDriveLoginScreen },
|
||||||
Log: { screen: LogScreen },
|
Log: { screen: LogScreen },
|
||||||
@ -237,15 +230,17 @@ class AppComponent extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Setting.setConstant('appId', 'net.cozic.joplin-android');
|
Setting.setConstant('env', __DEV__ ? 'dev' : 'prod');
|
||||||
|
Setting.setConstant('appId', 'net.cozic.joplin');
|
||||||
Setting.setConstant('appType', 'mobile');
|
Setting.setConstant('appType', 'mobile');
|
||||||
|
Setting.setConstant('resourceDir', RNFetchBlob.fs.dirs.DocumentDir);
|
||||||
|
|
||||||
const logDatabase = new Database(new DatabaseDriverReactNative());
|
const logDatabase = new Database(new DatabaseDriverReactNative());
|
||||||
await logDatabase.open({ name: 'log.sqlite' });
|
await logDatabase.open({ name: 'log.sqlite' });
|
||||||
await logDatabase.exec(Logger.databaseCreateTableSql());
|
await logDatabase.exec(Logger.databaseCreateTableSql());
|
||||||
reg.logger().addTarget('database', { database: logDatabase, source: 'm' });
|
reg.logger().addTarget('database', { database: logDatabase, source: 'm' });
|
||||||
|
|
||||||
reg.logger().info('Starting application' + Setting.value('appId'));
|
reg.logger().info('Starting application ' + Setting.value('appId') + ' (' + Setting.value('env') + ')');
|
||||||
|
|
||||||
let db = new JoplinDatabase(new DatabaseDriverReactNative());
|
let db = new JoplinDatabase(new DatabaseDriverReactNative());
|
||||||
reg.setDb(db);
|
reg.setDb(db);
|
||||||
@ -261,23 +256,24 @@ class AppComponent extends React.Component {
|
|||||||
BaseItem.loadClass('NoteTag', NoteTag);
|
BaseItem.loadClass('NoteTag', NoteTag);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await db.open({ name: 'joplin-50.sqlite' })
|
if (Setting.value('env') == 'prod') {
|
||||||
|
await db.open({ name: 'joplin.sqlite' })
|
||||||
|
} else {
|
||||||
|
await db.open({ name: 'joplin-51.sqlite' })
|
||||||
|
|
||||||
|
// await db.exec('DELETE FROM notes');
|
||||||
|
// await db.exec('DELETE FROM folders');
|
||||||
|
// await db.exec('DELETE FROM tags');
|
||||||
|
// await db.exec('DELETE FROM note_tags');
|
||||||
|
// await db.exec('DELETE FROM resources');
|
||||||
|
// await db.exec('DELETE FROM deleted_items');
|
||||||
|
}
|
||||||
|
|
||||||
reg.logger().info('Database is ready.');
|
reg.logger().info('Database is ready.');
|
||||||
|
|
||||||
//await db.exec('DELETE FROM notes');
|
|
||||||
//await db.exec('DELETE FROM folders');
|
|
||||||
//await db.exec('DELETE FROM tags');
|
|
||||||
//await db.exec('DELETE FROM note_tags');
|
|
||||||
//await db.exec('DELETE FROM resources');
|
|
||||||
//await db.exec('DELETE FROM deleted_items');
|
|
||||||
|
|
||||||
reg.logger().info('Loading settings...');
|
reg.logger().info('Loading settings...');
|
||||||
await Setting.load();
|
await Setting.load();
|
||||||
|
|
||||||
Setting.setConstant('resourceDir', RNFetchBlob.fs.dirs.DocumentDir);
|
|
||||||
|
|
||||||
reg.logger().info('Loading folders...');
|
reg.logger().info('Loading folders...');
|
||||||
|
|
||||||
let folders = await Folder.all();
|
let folders = await Folder.all();
|
||||||
|
|
||||||
this.props.dispatch({
|
this.props.dispatch({
|
||||||
|
Loading…
Reference in New Issue
Block a user