1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-11-27 08:21:03 +02:00

Changed to use object properties

This commit is contained in:
Laurent Cozic 2017-10-07 21:04:53 +01:00
parent b98e0b945f
commit 6a3eb65a66
3 changed files with 32 additions and 14 deletions

View File

@ -46,7 +46,7 @@ class AppGui {
rootWidget.setName('rootWidget');
const folderList = new ListWidget();
folderList.setItems([]);
folderList.items = [];
folderList.setItemRenderer((item) => {
return item.title;
});
@ -56,13 +56,13 @@ class AppGui {
folderList.setName('folderList');
folderList.setVStretch(true);
folderList.on('currentItemChange', async () => {
const folder = folderList.currentItem();
const folder = folderList.currentItem;
this.app().switchCurrentFolder(folder);
await this.updateNoteList(folder ? folder.id : null);
});
const noteList = new ListWidget();
noteList.setItems([]);
noteList.items = [];
noteList.setItemRenderer((note) => {
let label = note.title;
if (note.is_todo) {
@ -78,7 +78,7 @@ class AppGui {
borderRightWidth: 1,
});
noteList.on('currentItemChange', async () => {
let note = noteList.currentItem();
let note = noteList.currentItem;
if (note) {
if (!('body' in note)) {
note = await Note.load(note.id);
@ -158,7 +158,7 @@ class AppGui {
if (!widget) return null;
if (widget.name() == 'noteList' || widget.name() == 'folderList') {
return widget.currentItem();
return widget.currentItem;
}
return null;
@ -168,12 +168,12 @@ class AppGui {
this.logger().info('Action:', action);
let state = Object.assign({}, defaultState);
state.notes = this.widget('noteList').items();
state.notes = this.widget('noteList').items;
let newState = reducer(state, action);
if (newState !== state) {
this.widget('noteList').setItems(newState.notes);
this.widget('noteList').items = newState.notes;
}
}
@ -203,8 +203,8 @@ class AppGui {
return;
}
let note = this.widget('noteList').currentItem();
let folder = this.widget('folderList').currentItem();
let note = this.widget('noteList').currentItem;
let folder = this.widget('folderList').currentItem;
let args = cliUtils.splitCommandString(cmd);
for (let i = 0; i < args.length; i++) {
@ -227,19 +227,19 @@ class AppGui {
async updateFolderList() {
const folders = await Folder.all();
this.widget('folderList').setItems(folders);
this.widget('folderList').items = folders;
}
async updateNoteList(folderId) {
const fields = Note.previewFields();
fields.splice(fields.indexOf('body'), 1);
const notes = folderId ? await Note.previews(folderId, { fields: fields }) : [];
this.widget('noteList').setItems(notes);
this.widget('noteList').items = notes;
}
async updateNoteText(note) {
const text = note ? note.body : '';
this.widget('noteText').setText(text);
this.widget('noteText').text = text;
}
async start() {

View File

@ -29,6 +29,7 @@
"promise": "^7.1.1",
"proper-lockfile": "^2.0.1",
"query-string": "4.3.4",
"redux": "^3.7.2",
"sax": "^1.2.2",
"server-destroy": "^1.0.1",
"source-map-support": "^0.4.15",

View File

@ -1611,6 +1611,10 @@ levenshtein@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/levenshtein/-/levenshtein-1.0.5.tgz#3911737a9cb56da345d008f55782c6f138979ba3"
lodash-es@^4.2.1:
version "4.17.4"
resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.4.tgz#dcc1d7552e150a0640073ba9cb31d70f032950e7"
lodash.assign@^4.2.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/lodash.assign/-/lodash.assign-4.2.0.tgz#0d99f3ccd7a6d261d19bdaeb9245005d285808e7"
@ -1623,11 +1627,11 @@ lodash.uniq@^4.5.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773"
lodash@^4.17.4, lodash@^4.2.0:
lodash@^4.17.4, lodash@^4.2.0, lodash@^4.2.1:
version "4.17.4"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae"
loose-envify@^1.0.0:
loose-envify@^1.0.0, loose-envify@^1.1.0:
version "1.3.1"
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.3.1.tgz#d1a8ad33fa9ce0e713d65fdd0ac8b748d478c848"
dependencies:
@ -2023,6 +2027,15 @@ redeyed@~1.0.0:
dependencies:
esprima "~3.0.0"
redux@^3.7.2:
version "3.7.2"
resolved "https://registry.yarnpkg.com/redux/-/redux-3.7.2.tgz#06b73123215901d25d065be342eb026bc1c8537b"
dependencies:
lodash "^4.2.1"
lodash-es "^4.2.1"
loose-envify "^1.1.0"
symbol-observable "^1.0.3"
regenerate@^1.2.1:
version "1.3.2"
resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.3.2.tgz#d1941c67bad437e1be76433add5b385f95b19260"
@ -2278,6 +2291,10 @@ supports-color@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7"
symbol-observable@^1.0.3:
version "1.0.4"
resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.0.4.tgz#29bf615d4aa7121bdd898b22d4b3f9bc4e2aa03d"
tar-pack@^3.4.0:
version "3.4.0"
resolved "https://registry.yarnpkg.com/tar-pack/-/tar-pack-3.4.0.tgz#23be2d7f671a8339376cbdb0b8fe3fdebf317984"