From 38f4bf6ffbaad37f1fc73281e20347cea8913592 Mon Sep 17 00:00:00 2001 From: kevdliu <1766838+kevdliu@users.noreply.github.com> Date: Tue, 12 Dec 2023 17:34:25 -0500 Subject: [PATCH] make list search case insensitive --- anylist/index.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/anylist/index.js b/anylist/index.js index 326c124..1f36f09 100644 --- a/anylist/index.js +++ b/anylist/index.js @@ -25,14 +25,17 @@ async function initialize(onInitialized) { async function getLists() { return initialize(async (any) => { - let lists = await any.getLists(); - return lists.map(list => list.name); + return any.lists.map(list => list.name); }); } +function getListByName(any, name) { + return any.lists.find(l => l.name.toUpperCase() === name.toUpperCase()); +} + async function getItems(listName) { return initialize(async (any) => { - let list = any.getListByName(listName); + let list = getListByName(any, listName); if (!list) { return null; } @@ -51,7 +54,7 @@ async function getItems(listName) { async function removeItemByName(listName, itemName) { return initialize(async (any) => { - let list = any.getListByName(listName); + let list = getListByName(any, listName); if (!list) { return 500; } @@ -68,7 +71,7 @@ async function removeItemByName(listName, itemName) { async function removeItemById(listName, itemId) { return initialize(async (any) => { - let list = any.getListByName(listName); + let list = getListByName(any, listName); if (!list) { return 500; } @@ -102,7 +105,7 @@ function lookupItemCategory(any, listId, itemName) { async function addItem(listName, itemName) { return initialize(async (any) => { - let list = any.getListByName(listName); + let list = getListByName(any, listName); if (!list) { return 500; } @@ -125,7 +128,7 @@ async function addItem(listName, itemName) { async function updateItem(listName, itemId, updates) { return initialize(async (any) => { - let list = any.getListByName(listName); + let list = getListByName(any, listName); if (!list) { return 500; } @@ -150,7 +153,7 @@ async function updateItem(listName, itemId, updates) { async function checkItem(listName, itemName, checked) { return initialize(async (any) => { - let list = any.getListByName(listName); + let list = getListByName(any, listName); if (!list) { return 500; }