Skip to content

Commit

Permalink
make list search case insensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
kevdliu committed Dec 12, 2023
1 parent cc43768 commit 38f4bf6
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions anylist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down

0 comments on commit 38f4bf6

Please sign in to comment.