Skip to content

Commit

Permalink
fix editing list item completed prop
Browse files Browse the repository at this point in the history
  • Loading branch information
586837r committed Mar 20, 2020
1 parent 8319fdd commit 3039d67
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions nodes/alexa-remote-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,28 @@ module.exports = function (RED) {
const config = tools.nodeEvaluateProperties(RED, this, msg, this.config);
if(!tools.matches(config, { option: '', value: undefined })) return error(`invalid input: "${JSON.stringify(config)}"`);
const {option, value} = config;

switch(option) {
case 'getLists':
return alexa.getListsPromise().then(send).catch(error);

return alexa.getListsPromise().then(send).catch(error);
case 'getList':
if(!tools.matches(value, { list: '' })) return error(`expected a string 'list'`);
return alexa.getListPromise(value.list).then(send).catch(error);

case 'getListItems':
if(!tools.matches(value, { list: '' })) return error(`expected a string 'list'`);
return alexa.getListItemsPromise(value.list).then(send).catch(error);

case 'addItem':
if(!tools.matches(value, { list: '', text: '' })) return error(`expected a string 'list' and 'text'`);
return alexa.addListItemPromise(value.list, value.text).then(send).catch(error);

return alexa.getListPromise(value.list).then(send).catch(error);

case 'getListItems':
if(!tools.matches(value, { list: '' })) return error(`expected a string 'list'`);
return alexa.getListItemsPromise(value.list).then(send).catch(error);

case 'addItem':
if(!tools.matches(value, { list: '', text: '' })) return error(`expected a string 'list' and 'text'`);
return alexa.addListItemPromise(value.list, value.text).then(send).catch(error);

case 'editItem':
if(!tools.matches(value, { list: '', item: '', text: '', completed: undefined, version: 0 })) return error(`expected a string 'list', 'item', 'text' and number 'version'`);
let options = { value: value.text, version: value.version };
if(typeof value.completed === 'boolean') options.completed = value.completed;
return alexa.updateListItemPromise(value.list, value.item, {value: value.text, version: value.version}).then(send).catch(error);
return alexa.updateListItemPromise(value.list, value.item, options).then(send).catch(error);

case 'removeItem':
if(!tools.matches(value, { list: '', item: '' })) return error(`expected a string 'list' and 'item'`);
Expand Down

0 comments on commit 3039d67

Please sign in to comment.