chiyadev / genshin-schedule

🕑 Genshin farming scheduler
https://genshin.chiya.dev
MIT License
72 stars 17 forks source link

Task search does not filter items in the task list #42

Closed luaneko closed 3 years ago

luaneko commented 3 years ago

Task list should be hiding mismatches but it does not. Current:

image

Expected:

image

Map is unaffected and works as expected.

lauslim12 commented 3 years ago

I think I found the bug.

I noticed that your useDueTasks utility function does not actually search for the query that we typed in the search box. So, I modified your useDueTasks code a bit and...

image

image

image

Works perfectly! What do you think? I can drop a PR if you wish!

luaneko commented 3 years ago

That would be great!

lauslim12 commented 3 years ago

I guess my solution was incorrect 😅.

Thanks for the feedback though, if I managed to find another solution that suits your feedback, I'll make a PR again.

lauslim12 commented 3 years ago

Hey, I think I managed to find a solution according to your feedback.

It's actually pretty simple, it goes like the following:

Old one:

const dueTasks = useDueTasks(tasks);

New one:

const dueTasks = useDueTasks(tasks);
const filteredTasks = useFilteredTasks(dueTasks); // after getting due tasks, filter them according to the user's query.

// The next parts are just replacing 'dueTasks' with 'filteredTasks'

I believe the reason of why the search button never worked - is because we never called useFilteredTasks in the first place. The reason the map worked fine is because we have called the useFilteredTasks function in the taskDispatches (TaskLayer component).

All of the changes happen in the TaskListCard.

What do you think? I tested in it my local machine and it works perfectly. Hope it doesn't incur any of negative side effects or bugs though!

luaneko commented 3 years ago

That's what I was looking for :)