diff --git a/lib/voice-assist.js b/lib/voice-assist.js index 5d183c7..44737f0 100644 --- a/lib/voice-assist.js +++ b/lib/voice-assist.js @@ -38,7 +38,7 @@ socket.on('addNotification', function(data) { console.log(data); //read file and see if the q-id is here - var questionID; + var uid = data.id; var message; console.log(" fewafew"); var obj = new Object(); @@ -46,22 +46,14 @@ socket.on('addNotification', function(data) { if (err == null){ obj = JSON.parse(fs.readFileSync(file, 'utf8')); console.log(obj); - if(!obj.hasOwnProperty(uid)){ - obj[uid] = { - response: [data.msg] - }; - }else{ - obj[uid].response.push(data.msg); + debugger; + if(obj.hasOwnProperty(uid)){ + console.log(); + obj[uid].response.push(data.msg); + atom.notifications.addSuccess("You received one response for this question:\n "+data.id + +"\n the response is: "+data.msg); } - - console.log(" hi fewafew"); - jsonfile.writeFile(file, obj, function (err) { - console.error(err) - }) - atom.notifications.addSuccess("You received one response for this question:\n "+data.id - +"\n the response is: "+data.msg); - } });