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

Electron: search

This commit is contained in:
Laurent Cozic 2017-11-17 18:57:27 +00:00
parent 2bfaa0e02c
commit 409f2ca98d
13 changed files with 243 additions and 108 deletions

BIN
Assets/All.psd Normal file

Binary file not shown.

BIN
Assets/Laptop-Terminal.psd Normal file

Binary file not shown.

BIN
Assets/Tablet.psd Normal file

Binary file not shown.

View File

@ -327,7 +327,7 @@ class AppGui {
this.stdout(_('To delete a tag, untag the associated notes.'));
} else if (item.type_ === BaseModel.TYPE_SEARCH) {
this.store().dispatch({
type: 'SEARCH_REMOVE',
type: 'SEARCH_DELETE',
id: item.id,
});
}

View File

@ -157,7 +157,7 @@ const footerHtml = `
// Grocery shopping list 📝
// Work itinerary
// Tuesday random note
// Vacation plans ☀
// Vacation plans ☀
// </pre>
// </td>
// </tr>

Binary file not shown.

View File

@ -1,6 +1,6 @@
{
"name": "demo-joplin",
"version": "1.0.6",
"version": "1.0.8",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -25,7 +25,7 @@
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz",
"integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==",
"requires": {
"color-convert": "1.9.0"
"color-convert": "1.9.1"
}
},
"app-module-path": {
@ -79,23 +79,6 @@
"resolved": "https://registry.npmjs.org/aws4/-/aws4-1.6.0.tgz",
"integrity": "sha1-g+9cqGCysy5KDe7e6MdxudtXRx4="
},
"babel-plugin-transform-runtime": {
"version": "6.23.0",
"resolved": "https://registry.npmjs.org/babel-plugin-transform-runtime/-/babel-plugin-transform-runtime-6.23.0.tgz",
"integrity": "sha1-iEkNRGUC6puOfvsP4J7E2ZR5se4=",
"requires": {
"babel-runtime": "6.26.0"
}
},
"babel-runtime": {
"version": "6.26.0",
"resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz",
"integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=",
"requires": {
"core-js": "2.5.1",
"regenerator-runtime": "0.11.0"
}
},
"bcrypt-pbkdf": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz",
@ -113,11 +96,6 @@
"hoek": "4.2.0"
}
},
"cache-require-paths": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/cache-require-paths/-/cache-require-paths-0.3.0.tgz",
"integrity": "sha1-EqYHWj5JiNpMIvIY4pSFZj5MSmM="
},
"camelcase": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz",
@ -165,18 +143,18 @@
"integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ="
},
"color": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/color/-/color-2.0.0.tgz",
"integrity": "sha1-4MmXLR6WmFcASxAeqlXOq1lh1n0=",
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color/-/color-2.0.1.tgz",
"integrity": "sha512-ubUCVVKfT7r2w2D3qtHakj8mbmKms+tThR8gI8zEYCbUBl8/voqFGt3kgBqGwXAopgXybnkuOq+qMYCRrp4cXw==",
"requires": {
"color-convert": "1.9.0",
"color-convert": "1.9.1",
"color-string": "1.5.2"
}
},
"color-convert": {
"version": "1.9.0",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.0.tgz",
"integrity": "sha1-Gsz5fdc5uYO/mU1W/sj5WFNkG3o=",
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz",
"integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==",
"requires": {
"color-name": "1.1.3"
}
@ -212,11 +190,6 @@
"proto-list": "1.2.4"
}
},
"core-js": {
"version": "2.5.1",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.1.tgz",
"integrity": "sha1-rmh03GaTd4m4B1T/VCjfZoGcpQs="
},
"core-util-is": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
@ -306,6 +279,53 @@
"jsbn": "0.1.1"
}
},
"emphasize": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/emphasize/-/emphasize-1.5.0.tgz",
"integrity": "sha1-48WvLdzLSYKCKjNJtHFhPMfOzJI=",
"requires": {
"chalk": "1.1.3",
"highlight.js": "9.12.0",
"lowlight": "1.9.1"
},
"dependencies": {
"ansi-regex": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
"integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8="
},
"ansi-styles": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz",
"integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4="
},
"chalk": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz",
"integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=",
"requires": {
"ansi-styles": "2.2.1",
"escape-string-regexp": "1.0.5",
"has-ansi": "2.0.0",
"strip-ansi": "3.0.1",
"supports-color": "2.0.0"
}
},
"strip-ansi": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
"integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
"requires": {
"ansi-regex": "2.1.1"
}
},
"supports-color": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz",
"integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc="
}
}
},
"encoding": {
"version": "0.1.12",
"resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz",
@ -395,7 +415,7 @@
"resolved": "https://registry.npmjs.org/get-proxy/-/get-proxy-2.1.0.tgz",
"integrity": "sha512-zmZIaQTWnNQb4R4fJUEp/FC51eZsc6EkErspy3xtIYStaq8EB/hDIWipxsal+E8rz0qD7f2sL/NA9Xee4RInJw==",
"requires": {
"npm-conf": "1.1.2"
"npm-conf": "1.1.3"
}
},
"getpass": {
@ -425,6 +445,21 @@
"har-schema": "2.0.0"
}
},
"has-ansi": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz",
"integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=",
"requires": {
"ansi-regex": "2.1.1"
},
"dependencies": {
"ansi-regex": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
"integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8="
}
}
},
"has-flag": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz",
@ -454,11 +489,21 @@
"sntp": "2.1.0"
}
},
"highlight.js": {
"version": "9.12.0",
"resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-9.12.0.tgz",
"integrity": "sha1-5tnb5Xy+/mB1HwKvM2GVhwyQwB4="
},
"hoek": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.0.tgz",
"integrity": "sha512-v0XCLxICi9nPfYrS9RL8HbYnXi9obYAeLbSP00BmnZwCK9+Ih9WOjoZ8YoHCoav2csqn4FOz4Orldsy2dmDwmQ=="
},
"html-entities": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/html-entities/-/html-entities-1.2.1.tgz",
"integrity": "sha1-DfKTUfByEWNRXfueVUPl9u7VFi8="
},
"http-signature": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz",
@ -577,22 +622,21 @@
}
},
"joplin": {
"version": "0.10.64",
"resolved": "https://registry.npmjs.org/joplin/-/joplin-0.10.64.tgz",
"integrity": "sha512-CdhUZCnbpGmvOJqpeJp4ri9kGk6nP+VxulbaJLx8MTWho8n3tBRHcvAGP/lOLovFvUy760lOyzqHiYfcimonJQ==",
"version": "0.10.69",
"resolved": "https://registry.npmjs.org/joplin/-/joplin-0.10.69.tgz",
"integrity": "sha512-P5b7pRiUqM2O/vG4etiAquGd7LM6j/eh93OmQgJmfcGu5F6D9DJERIjBP8Po/BnzXQVxsGnURHr3SmLlaUxQSg==",
"requires": {
"app-module-path": "2.2.0",
"babel-plugin-transform-runtime": "6.23.0",
"cache-require-paths": "0.3.0",
"follow-redirects": "1.2.5",
"form-data": "2.3.1",
"fs-extra": "3.0.1",
"html-entities": "1.2.1",
"jssha": "2.3.1",
"levenshtein": "1.0.5",
"lodash": "4.17.4",
"md5": "2.2.1",
"mime": "2.0.3",
"moment": "2.19.1",
"moment": "2.19.2",
"node-fetch": "1.7.3",
"node-persist": "2.1.0",
"os-tmpdir": "1.0.2",
@ -603,14 +647,13 @@
"sax": "1.2.4",
"server-destroy": "1.0.1",
"sharp": "0.18.4",
"source-map-support": "0.4.18",
"sprintf-js": "1.1.1",
"sqlite3": "3.1.13",
"string-padding": "1.0.2",
"string-to-stream": "1.1.0",
"strip-ansi": "4.0.0",
"tcp-port-used": "0.1.2",
"tkwidgets": "0.5.19",
"tkwidgets": "0.5.20",
"uuid": "3.1.0",
"word-wrap": "1.2.3",
"yargs-parser": "7.0.0"
@ -719,6 +762,14 @@
"js-tokens": "3.0.2"
}
},
"lowlight": {
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/lowlight/-/lowlight-1.9.1.tgz",
"integrity": "sha512-CpDhyVhI+xHjruiGvH2F/Fr5q5aTn5A6Oyh7MI+4oI8G0A1E7p9a3Zqv9Hzx9WByK8gAiNifEueAXz+cA2xdEA==",
"requires": {
"highlight.js": "9.12.0"
}
},
"md5": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/md5/-/md5-2.2.1.tgz",
@ -782,9 +833,9 @@
}
},
"moment": {
"version": "2.19.1",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.19.1.tgz",
"integrity": "sha1-VtoaLRy/AdOLfhr8McELz6GSkWc="
"version": "2.19.2",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.19.2.tgz",
"integrity": "sha512-Rf6jiHPEfxp9+dlzxPTmRHbvoFXsh2L/U8hOupUMpnuecHQmI6cF6lUbJl3QqKPko1u6ujO+FxtcajLVfLpAtA=="
},
"ms": {
"version": "2.0.0",
@ -792,9 +843,9 @@
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
},
"nan": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.7.0.tgz",
"integrity": "sha1-2Vv3IeyHfgjbJ27T/G63j5CDrUY="
"version": "2.8.0",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.8.0.tgz",
"integrity": "sha1-7XFfP+neArV6XmJS2QqWZ14fCFo="
},
"ndarray": {
"version": "1.0.18",
@ -850,9 +901,9 @@
}
},
"npm-conf": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/npm-conf/-/npm-conf-1.1.2.tgz",
"integrity": "sha512-dotwbpwVzfNB/2EF3A2wjK5tEMLggKfuA/8TG6WvBB1Zrv+JsvF7E8ei9B/HGq211st/GwXFbREcNJvJ1eySUQ==",
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/npm-conf/-/npm-conf-1.1.3.tgz",
"integrity": "sha512-Yic4bZHJOt9RCFbRP3GgpqhScOY4HH3V2P8yBj6CeYq118Qr+BLXqT2JvpJ00mryLESpgOxf5XlFv4ZjXxLScw==",
"requires": {
"config-chain": "1.1.11",
"pify": "3.0.0"
@ -985,11 +1036,6 @@
"symbol-observable": "1.0.4"
}
},
"regenerator-runtime": {
"version": "0.11.0",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.0.tgz",
"integrity": "sha512-/aA0kLeRb5N9K0d4fw7ooEbI+xDe+DKD499EQqygGqeS8N3xto15p09uY2xj7ixP81sNPXvRLnAQIqdVStgb1A=="
},
"request": {
"version": "2.83.0",
"resolved": "https://registry.npmjs.org/request/-/request-2.83.0.tgz",
@ -1050,9 +1096,9 @@
"integrity": "sha1-/jKcDwaJbCiqJDdt8f/wKuV/LTQ=",
"requires": {
"caw": "2.0.1",
"color": "2.0.0",
"color": "2.0.1",
"detect-libc": "0.2.0",
"nan": "2.7.0",
"nan": "2.8.0",
"semver": "5.4.1",
"simple-get": "2.7.0",
"tar": "3.2.1"
@ -1097,19 +1143,6 @@
"hoek": "4.2.0"
}
},
"source-map": {
"version": "0.5.7",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz",
"integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w="
},
"source-map-support": {
"version": "0.4.18",
"resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.4.18.tgz",
"integrity": "sha512-try0/JqxPLF9nOjvSta7tVondkP5dwgyLDjVoyMDlmjugT2lRZ1OfsrYTkCd2hkDnJTKRbO/Rl3orm8vlsUzbA==",
"requires": {
"source-map": "0.5.7"
}
},
"sprintf-js": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.1.tgz",
@ -1518,6 +1551,11 @@
"version": "2.0.0",
"bundled": true
},
"nan": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.7.0.tgz",
"integrity": "sha1-2Vv3IeyHfgjbJ27T/G63j5CDrUY="
},
"node-pre-gyp": {
"version": "0.6.38",
"bundled": true,
@ -1947,9 +1985,9 @@
}
},
"terminal-kit": {
"version": "1.14.0",
"resolved": "https://registry.npmjs.org/terminal-kit/-/terminal-kit-1.14.0.tgz",
"integrity": "sha512-ir0I2QtcBDSg2w0UvohlqdDpGlS3S2UYBG4NnYKnK/4VywgnbfxgdpXN3el0uCH3OeH6fG38luW7RmDM96FqUw==",
"version": "1.14.3",
"resolved": "https://registry.npmjs.org/terminal-kit/-/terminal-kit-1.14.3.tgz",
"integrity": "sha512-ZHtuElnBhK0IXOYNvQ7eYgaArwEoOv7saQc4Q0Z9p02JeC7iajC20/odV77BKB3jw/Qthvf9mpASf8gNDYv7xQ==",
"requires": {
"async-kit": "2.2.3",
"get-pixels": "3.3.0",
@ -1965,15 +2003,16 @@
"integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU="
},
"tkwidgets": {
"version": "0.5.19",
"resolved": "https://registry.npmjs.org/tkwidgets/-/tkwidgets-0.5.19.tgz",
"integrity": "sha512-Etskz52RInmmB1aGD9cIodIZ33Gwf0yPP3+lh6ceANgS4N8LpquQajDRyahjZnvwDhfYdo1N87eEKzXBJbLQDg==",
"version": "0.5.20",
"resolved": "https://registry.npmjs.org/tkwidgets/-/tkwidgets-0.5.20.tgz",
"integrity": "sha512-9wGsMrrFJvE/6TKUc0dEFFhwxvZLeNsYOxnpy1JCwyk/hYCEF70nuvk7VvJeG4TPaQBaGKPj6c7pCgdREvz4Jw==",
"requires": {
"chalk": "2.3.0",
"emphasize": "1.5.0",
"node-emoji": "git+https://github.com/laurent22/node-emoji.git#9fa01eac463e94dde1316ef8c53089eeef4973b5",
"slice-ansi": "1.0.0",
"string-width": "2.1.1",
"terminal-kit": "1.14.0",
"terminal-kit": "1.14.3",
"wrap-ansi": "3.0.1"
}
},

View File

@ -1,6 +1,6 @@
{
"name": "demo-joplin",
"version": "1.0.6",
"version": "1.0.8",
"description": "Demo for Joplin CLI",
"bin": {
"demo-joplin": "./index.js"
@ -25,7 +25,7 @@
},
"dependencies": {
"fs-extra": "^4.0.2",
"joplin": "^0.10.64"
"joplin": "^0.10.69"
},
"author": "Laurent Cozic",
"license": "MIT"

View File

@ -219,6 +219,36 @@ class Application extends BaseApplication {
accelerator: 'CommandOrControl+Q',
click: () => { bridge().electronApp().exit() }
}]
}, {
label: _('Edit'),
submenu: [{
label: _('Copy'),
screens: ['Main'],
role: 'copy',
accelerator: 'CommandOrControl+C',
}, {
label: _('Cut'),
screens: ['Main'],
role: 'copy',
accelerator: 'CommandOrControl+X',
}, {
label: _('Paste'),
screens: ['Main'],
role: 'copy',
accelerator: 'CommandOrControl+V',
}, {
type: 'separator',
}, {
label: _('Search in all the notes'),
screens: ['Main'],
accelerator: 'F6',
click: () => {
this.dispatch({
type: 'WINDOW_COMMAND',
name: 'search',
});
},
}]
}, {
label: _('Tools'),
submenu: [{

View File

@ -6,8 +6,10 @@ const { NoteList } = require('./NoteList.min.js');
const { NoteText } = require('./NoteText.min.js');
const { PromptDialog } = require('./PromptDialog.min.js');
const { Setting } = require('lib/models/setting.js');
const { BaseModel } = require('lib/base-model.js');
const { Tag } = require('lib/models/tag.js');
const { Note } = require('lib/models/note.js');
const { uuid } = require('lib/uuid.js');
const { Folder } = require('lib/models/folder.js');
const { themeStyle } = require('../theme.js');
const { _ } = require('lib/locale.js');
@ -149,6 +151,34 @@ class MainScreenComponent extends React.Component {
}
},
});
} else if (command.name === 'search') {
this.setState({
promptOptions: {
label: _('Seach:'),
onClose: async (answer) => {
if (answer !== null) {
const searchId = uuid.create();
this.props.dispatch({
type: 'SEARCH_ADD',
search: {
id: searchId,
title: answer,
query_pattern: answer,
query_folder_id: null,
type_: BaseModel.TYPE_SEARCH,
},
});
this.props.dispatch({
type: 'SEARCH_SELECT',
id: searchId,
});
}
this.setState({ promptOptions: null });
}
},
});
} else {
commandProcessed = false;
}
@ -222,6 +252,12 @@ class MainScreenComponent extends React.Component {
onClick: () => { this.doCommand({ name: 'newNotebook' }) },
});
headerButtons.push({
title: _('Seach'),
iconName: 'fa-search',
onClick: () => { this.doCommand({ name: 'search' }) },
});
headerButtons.push({
title: _('Layout'),
iconName: 'fa-columns',

View File

@ -100,6 +100,8 @@ class SideBarComponent extends React.Component {
deleteMessage = _('Delete notebook?');
} else if (itemType === BaseModel.TYPE_TAG) {
deleteMessage = _('Remove this tag from all the notes?');
} else if (itemType === BaseModel.TYPE_SEARCH) {
deleteMessage = _('Remove this search from the sidebar?');
}
const menu = new Menu();
@ -112,9 +114,15 @@ class SideBarComponent extends React.Component {
await Folder.delete(itemId);
} else if (itemType === BaseModel.TYPE_TAG) {
await Tag.untagAll(itemId);
} else if (itemType === BaseModel.TYPE_SEARCH) {
this.props.dispatch({
type: 'SEARCH_DELETE',
id: itemId,
});
}
}}))
if (itemType === BaseModel.TYPE_FOLDER) {
menu.append(new MenuItem({label: _('Rename'), click: async () => {
this.props.dispatch({
type: 'WINDOW_COMMAND',
@ -122,6 +130,7 @@ class SideBarComponent extends React.Component {
id: itemId,
});
}}))
}
menu.popup(bridge().window());
}
@ -140,6 +149,13 @@ class SideBarComponent extends React.Component {
});
}
searchItem_click(search) {
this.props.dispatch({
type: 'SEARCH_SELECT',
id: search ? search.id : null,
});
}
async sync_click() {
await shared.synchronize_press(this);
}
@ -157,6 +173,12 @@ class SideBarComponent extends React.Component {
return <a className="list-item" href="#" data-id={tag.id} data-type={BaseModel.TYPE_TAG} onContextMenu={(event) => this.itemContextMenu(event)} key={tag.id} style={style} onClick={() => {this.tagItem_click(tag)}}>{tag.title}</a>
}
searchItem(search, selected) {
let style = Object.assign({}, this.style().listItem);
if (selected) style = Object.assign(style, this.style().listItemSelected);
return <a className="list-item" href="#" data-id={search.id} data-type={BaseModel.TYPE_SEARCH} onContextMenu={(event) => this.itemContextMenu(event)} key={search.id} style={style} onClick={() => {this.searchItem_click(search)}}>{search.title}</a>
}
makeDivider(key) {
return <div style={{height:2, backgroundColor:'blue' }} key={key}></div>
}
@ -196,6 +218,14 @@ class SideBarComponent extends React.Component {
items.push(<div className="tags" key="tag_items">{tagItems}</div>);
}
if (this.props.searches.length) {
items.push(this.makeHeader('searchHeader', _('Searches'), 'fa-search'));
const searchItems = shared.renderSearches(this.props, this.searchItem.bind(this));
items.push(<div className="searches" key="search_items">{searchItems}</div>);
}
let lines = Synchronizer.reportToLines(this.props.syncReport);
const syncReportText = [];
for (let i = 0; i < lines.length; i++) {
@ -219,10 +249,12 @@ const mapStateToProps = (state) => {
return {
folders: state.folders,
tags: state.tags,
searches: state.searches,
syncStarted: state.syncStarted,
syncReport: state.syncReport,
selectedFolderId: state.selectedFolderId,
selectedTagId: state.selectedTagId,
selectedSearchId: state.selectedSearchId,
notesParentType: state.notesParentType,
locale: state.settings.locale,
theme: state.settings.theme,

View File

@ -20,6 +20,16 @@ shared.renderTags = function(props, renderItem) {
return tagItems;
}
shared.renderSearches = function(props, renderItem) {
let searches = props.searches.slice();
let searchItems = [];
for (let i = 0; i < searches.length; i++) {
const search = searches[i];
searchItems.push(renderItem(search, props.selectedSearchId == search.id && props.notesParentType == 'Search'));
}
return searchItems;
}
shared.synchronize_press = async function(comp) {
const { Setting } = require('lib/models/setting.js');
const { reg } = require('lib/registry.js');

View File

@ -35,6 +35,7 @@ function handleItemDelete(state, action) {
'FOLDER_DELETE': ['folders', 'selectedFolderId'],
'NOTE_DELETE': ['notes', 'selectedNoteId'],
'TAG_DELETE': ['tags', 'selectedTagId'],
'SEARCH_DELETE': ['searches', 'selectedSearchId'],
};
const listKey = map[action.type][0];
@ -291,22 +292,9 @@ const reducer = (state = defaultState, action) => {
newState.searches = searches;
break;
case 'SEARCH_REMOVE':
case 'SEARCH_DELETE':
let foundIndex = -1;
for (let i = 0; i < state.searches.length; i++) {
if (state.searches[i].id === action.id) {
foundIndex = i;
break;
}
}
if (foundIndex >= 0) {
newState = Object.assign({}, state);
let newSearches = newState.searches.slice();
newSearches.splice(foundIndex, 1);
newState.searches = newSearches;
}
newState = handleItemDelete(state, action);
break;
case 'SEARCH_SELECT':