Skip to content

Commit

Permalink
Make plugin settings available to the plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
BrainMaestro committed Mar 10, 2017
1 parent 55755f2 commit 4fdee9e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion app/main/actions/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,22 @@ const DEFAULT_SCOPE = {
* @param {Function} callback Callback function that receives used search term and found results
*/
const eachPlugin = (term, display) => {
const externalSettings = config.get('external') || {}
// TODO: order results by frequency?
Object.keys(plugins).forEach(name => {
const settings = externalSettings[name]
if (settings) {
Object.keys(settings).forEach(key => settings[key] = settings[key].value)
}

try {
plugins[name].fn({
...DEFAULT_SCOPE,
term,
hide: (id) => store.dispatch(hideElement(`${name}-${id}`)),
update: (id, result) => store.dispatch(updateElement(`${name}-${id}`, result)),
display: (payload) => display(name, payload)
display: (payload) => display(name, payload),
settings,
})
} catch (error) {
// Do not fail on plugin errors, just log them to console
Expand Down

0 comments on commit 4fdee9e

Please sign in to comment.