diff --git a/js/search/search.js b/js/search/search.js index 81ab1ec7..c8de6fd4 100644 --- a/js/search/search.js +++ b/js/search/search.js @@ -6,6 +6,7 @@ const electron = require('electron'); const childProcess = require('child_process'); const app = electron.app; const path = require('path'); +const isObject = require('lodash.isplainobject'); const isDevEnv = require('../utils/misc.js').isDevEnv; const isMac = require('../utils/misc.js').isMac; @@ -151,15 +152,15 @@ class Search { * @param message */ realTimeIndexing(message) { - if (!Array.isArray(message)) { - return new Error('Messages should be an array'); + if (!message && !isObject(JSON.parse(message))) { + return new Error('Messages must be an object'); } if (!this.isInitialized) { return new Error('Library not initialized'); } - let result = libSymphonySearch.symSEIndexRealTime(this.realTimeIndex, JSON.stringify(message)); + let result = libSymphonySearch.symSEIndexRealTime(this.realTimeIndex, [ message ]); return result === 0 ? "Successful" : result } diff --git a/package.json b/package.json index feceb943..85a8513e 100644 --- a/package.json +++ b/package.json @@ -109,6 +109,7 @@ "ffi": "^2.2.0", "filesize": "^3.5.10", "keymirror": "0.1.1", + "lodash.isplainobject": "^4.0.6", "node-forge": "^0.7.1", "randomstring": "^1.1.5", "ref": "^1.3.4",