You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-06-15 23:00:36 +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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user