1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

various changes

This commit is contained in:
Laurent Cozic 2017-07-12 23:32:08 +01:00
parent 74e112fef9
commit d92f1c7eba
9 changed files with 62 additions and 26 deletions

View File

@ -90,8 +90,8 @@ android {
applicationId "net.cozic.joplin"
minSdkVersion 16
targetSdkVersion 22
versionCode 8
versionName "0.8.6"
versionCode 10
versionName "0.8.8"
ndk {
abiFilters "armeabi-v7a", "x86"
}

View File

@ -76,13 +76,13 @@ class ScreenHeaderComponent extends Component {
let title = 'title' in this.props && this.props.title !== null ? this.props.title : _(this.props.navState.routeName);
return (
<View style={{ flexDirection: 'row', padding: 10, backgroundColor: '#ffffff', alignItems: 'center' }} >
<View style={{ flexDirection: 'row', paddingLeft: 10, paddingTop: 10, paddingBottom: 10, paddingRight: 0, backgroundColor: '#ffffff', alignItems: 'center' }} >
<Button title="☰" onPress={() => this.sideMenuButton_press()} />
<Button disabled={!this.props.historyCanGoBack} title="<" onPress={() => this.backButton_press()}></Button>
<Text style={{ flex:1, marginLeft: 10 }} >{title}</Text>
<Menu onSelect={(value) => this.menu_select(value)}>
<MenuTrigger>
<Text style={{ fontSize: 20 }}> &#8942; </Text>
<Text style={{ fontSize: 25 }}> &#8942; </Text>
</MenuTrigger>
<MenuOptions>
{ menuOptionComponents }

View File

@ -8,6 +8,7 @@ import { ScreenHeader } from 'lib/components/screen-header.js';
import { MenuOption, Text } from 'react-native-popup-menu';
import { _ } from 'lib/locale.js';
import { ActionButton } from 'lib/components/action-button.js';
import DialogBox from 'react-native-dialogbox';
class NotesScreenComponent extends React.Component {
@ -16,6 +17,9 @@ class NotesScreenComponent extends React.Component {
}
deleteFolder_onPress(folderId) {
let ok = confirm(_('Delete notebook?'));
if (!ok) return;
Folder.delete(folderId).then(() => {
this.props.dispatch({
type: 'Navigation/NAVIGATE',

View File

@ -7,6 +7,7 @@ import { ScreenHeader } from 'lib/components/screen-header.js';
import { time } from 'lib/time-utils'
import { Logger } from 'lib/logger.js';
import { BaseItem } from 'lib/models/base-item.js';
import { Folder } from 'lib/models/folder.js';
import { _ } from 'lib/locale.js';
class StatusScreenComponent extends React.Component {
@ -18,7 +19,7 @@ class StatusScreenComponent extends React.Component {
constructor() {
super();
this.state = {
report: {},
reportLines: [],
};
}
@ -26,15 +27,11 @@ class StatusScreenComponent extends React.Component {
this.resfreshScreen();
}
resfreshScreen() {
return BaseItem.stats().then((report) => {
this.setState({ report: report });
});
}
render() {
async resfreshScreen() {
let r = await BaseItem.stats();
let reportLines = [];
const r = this.state.report;
reportLines.push(_('Sync status (sync items / total items):'));
for (let n in r.items) {
if (!r.items.hasOwnProperty(n)) continue;
@ -44,12 +41,26 @@ class StatusScreenComponent extends React.Component {
if (r.total) reportLines.push(_('Total: %d/%d', r.total.synced, r.total.total));
if (r.toDelete) reportLines.push(_('To delete: %d', r.toDelete.total));
reportLines = reportLines.join("\n");
reportLines.push('');
reportLines.push(_('Folders:'));
let folders = await Folder.all();
for (let i = 0; i < folders.length; i++) {
let folder = folders[i];
reportLines.push(_('%s: %d notes', folders[i].title, await Folder.noteCount(folders[i].id)));
}
this.setState({ reportLines: reportLines });
}
render() {
let report = this.state.reportLines ? this.state.reportLines.join("\n") : '';
return (
<View style={{flex: 1}}>
<ScreenHeader navState={this.props.navigation.state} />
<Text style={{padding: 6, flex: 1, textAlignVertical: 'top'}} multiline={true}>{reportLines}</Text>
<Text style={{padding: 6, flex: 1, textAlignVertical: 'top'}} multiline={true}>{report}</Text>
<Button title="Refresh" onPress={() => this.resfreshScreen()}/>
</View>
);

View File

@ -127,6 +127,14 @@ class FileApiDriverOneDrive {
}
async move(oldPath, newPath) {
// Cannot work in an atomic way because if newPath already exist, the OneDrive API throw an error
// "An item with the same name already exists under the parent". Some posts suggest to use
// @name.conflictBehavior [0]but that doesn't seem to work. So until Microsoft fixes this
// it's not possible to do an atomic move.
//
// [0] https://stackoverflow.com/questions/29191091/onedrive-api-overwrite-on-move
throw new Error('NOT WORKING');
let previousItem = await this.statRaw_(oldPath);
let newDir = dirname(newPath);

View File

@ -69,8 +69,8 @@ class OneDriveApi {
}
async appDirectory() {
let r = await this.execJson('GET', '/drive/special/approot');
return r.parentReference.path + '/' + r.name;
let r = await this.execJson('GET', '/drive/special/approot');
return r.parentReference.path + '/' + r.name;
}
authCodeUrl(redirectUri) {
@ -160,10 +160,16 @@ class OneDriveApi {
options.headers['Authorization'] = 'bearer ' + this.token();
let response = null;
if (options.target == 'string') {
response = await shim.fetch(url, options);
} else { // file
response = await shim.fetchBlob(url, options);
try {
if (options.target == 'string') {
response = await shim.fetch(url, options);
} else { // file
response = await shim.fetchBlob(url, options);
}
} catch (error) {
// TEMPORARY: To try to find where uncaught error comes from
let error = new Error('OneDrive API caught: ' + error.message);
throw error;
}
if (!response.ok) {

View File

@ -214,11 +214,17 @@ class Synchronizer {
// Make the operation atomic by doing the work on a copy of the file
// and then copying it back to the original location.
let tempPath = this.syncDirName_ + '/' + path + '_' + time.unixMs();
// let tempPath = this.syncDirName_ + '/' + path + '_' + time.unixMs();
//
// Atomic operation is disabled for now because it's not possible
// to do an atomic move with OneDrive (see file-api-driver-onedrive.js)
await this.api().put(tempPath, content);
await this.api().setTimestamp(tempPath, local.updated_time);
await this.api().move(tempPath, path);
// await this.api().put(tempPath, content);
// await this.api().setTimestamp(tempPath, local.updated_time);
// await this.api().move(tempPath, path);
await this.api().put(path, content);
await this.api().setTimestamp(path, local.updated_time);
if (this.randomFailure(options, 0)) return;

View File

@ -15,6 +15,7 @@
"react": "16.0.0-alpha.12",
"react-native": "0.46.0",
"react-native-action-button": "^2.6.9",
"react-native-dialogbox": "^0.6.6",
"react-native-fetch-blob": "^0.10.6",
"react-native-fs": "^2.3.3",
"react-native-popup-menu": "^0.7.4",

View File

@ -257,7 +257,7 @@ async function initialize(dispatch, backButtonHandler) {
if (Setting.value('env') == 'prod') {
await db.open({ name: 'joplin.sqlite' })
} else {
await db.open({ name: 'joplin-53.sqlite' })
await db.open({ name: 'joplin-55.sqlite' })
// await db.exec('DELETE FROM notes');
// await db.exec('DELETE FROM folders');