You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2026-05-22 09:05:38 +02:00
Fixed note edition
This commit is contained in:
@@ -99,53 +99,32 @@ class NoteScreenComponent extends BaseScreenComponent {
|
||||
return !!Object.getOwnPropertyNames(diff).length;
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
async componentWillMount() {
|
||||
BackHandler.addEventListener('hardwareBackPress', this.backHandler);
|
||||
|
||||
let note = null;
|
||||
let mode = 'view';
|
||||
if (!this.props.noteId) {
|
||||
let note = this.props.itemType == 'todo' ? Note.newTodo(this.props.folderId) : Note.new(this.props.folderId);
|
||||
this.setState({
|
||||
lastSavedNote: Object.assign({}, note),
|
||||
note: note,
|
||||
mode: 'edit',
|
||||
});
|
||||
this.refreshNoteMetadata();
|
||||
note = this.props.itemType == 'todo' ? Note.newTodo(this.props.folderId) : Note.new(this.props.folderId);
|
||||
mode = 'edit';
|
||||
} else {
|
||||
Note.load(this.props.noteId).then((note) => {
|
||||
this.setState({
|
||||
lastSavedNote: Object.assign({}, note),
|
||||
note: note,
|
||||
});
|
||||
this.refreshNoteMetadata();
|
||||
});
|
||||
note = await Note.load(this.props.noteId);
|
||||
}
|
||||
|
||||
this.refreshFolder();
|
||||
this.setState({
|
||||
lastSavedNote: Object.assign({}, note),
|
||||
note: note,
|
||||
mode: mode,
|
||||
folder: await Folder.load(note.parent_id),
|
||||
});
|
||||
|
||||
this.refreshNoteMetadata();
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
BackHandler.removeEventListener('hardwareBackPress', this.backHandler);
|
||||
}
|
||||
|
||||
async currentFolder() {
|
||||
let folderId = this.props.folderId;
|
||||
if (!folderId) {
|
||||
if (this.state.note && this.state.note.parent_id) folderId = this.state.note.parent_id;
|
||||
}
|
||||
|
||||
if (!folderId) return Folder.defaultFolder();
|
||||
|
||||
return Folder.load(folderId);
|
||||
}
|
||||
|
||||
async refreshFolder(folderId = null) {
|
||||
if (!folderId) {
|
||||
this.setState({ folder: await this.currentFolder() });
|
||||
} else {
|
||||
this.setState({ folder: await Folder.load(folderId) });
|
||||
}
|
||||
}
|
||||
|
||||
noteComponent_change(propName, propValue) {
|
||||
let note = Object.assign({}, this.state.note);
|
||||
note[propName] = propValue;
|
||||
@@ -448,7 +427,7 @@ class NoteScreenComponent extends BaseScreenComponent {
|
||||
let output = [];
|
||||
for (let i = 0; i < this.props.folders.length; i++) {
|
||||
let f = this.props.folders[i];
|
||||
output.push({ label: f.title, value: f.id });
|
||||
output.push({ label: f.title + ' ' + f.id, value: f.id });
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
@@ -106,6 +106,8 @@ class FileApiDriverLocal {
|
||||
}
|
||||
}
|
||||
|
||||
output = output.concat(deletedItems);
|
||||
|
||||
return {
|
||||
hasMore: false,
|
||||
context: null,
|
||||
|
||||
@@ -73,9 +73,14 @@ class BaseItem extends BaseModel {
|
||||
}
|
||||
|
||||
// Returns the IDs of the items that have been synced at least once
|
||||
static async syncedItems(syncTarget) {
|
||||
static async syncedItemIds(syncTarget) {
|
||||
if (!syncTarget) throw new Error('No syncTarget specified');
|
||||
return await this.db().selectAll('SELECT item_id, item_type FROM sync_items WHERE sync_time > 0 AND sync_target = ?', [syncTarget]);
|
||||
let temp = await this.db().selectAll('SELECT item_id FROM sync_items WHERE sync_time > 0 AND sync_target = ?', [syncTarget]);
|
||||
let output = [];
|
||||
for (let i = 0; i < temp.length; i++) {
|
||||
output.push(temp[i].item_id);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
static pathToId(path) {
|
||||
|
||||
@@ -105,6 +105,7 @@ class Synchronizer {
|
||||
if (n == 'starting') continue;
|
||||
if (n == 'finished') continue;
|
||||
if (n == 'state') continue;
|
||||
if (n == 'completedTime') continue;
|
||||
this.logger().info(n + ': ' + (report[n] ? report[n] : '-'));
|
||||
}
|
||||
let folderCount = await Folder.count();
|
||||
@@ -339,13 +340,14 @@ class Synchronizer {
|
||||
|
||||
let allIds = null;
|
||||
if (!this.api().supportsDelta()) {
|
||||
allIds = await BaseItem.syncedItems(syncTargetId);
|
||||
allIds = await BaseItem.syncedItemIds(syncTargetId);
|
||||
}
|
||||
|
||||
let listResult = await this.api().delta('', {
|
||||
context: context,
|
||||
itemIds: allIds,
|
||||
});
|
||||
|
||||
let remotes = listResult.items;
|
||||
for (let i = 0; i < remotes.length; i++) {
|
||||
if (this.cancelling()) break;
|
||||
|
||||
Reference in New Issue
Block a user