ahonn / logseq-plugin-todo

A simple to-do list plugin for logseq
MIT License
157 stars 11 forks source link

Add option to search from task create box #29

Closed meain closed 1 year ago

meain commented 1 year ago

This lets you search when inputting. It still retains ability to create tasks. One possible improvement could be clearing the input box when closing/hiding the plugin modal.

ahonn commented 1 year ago

That's good idea, but maybe we can through create a new Recoil Atom to store user's input, and filter task when is not empty. Some thing like that:

// state/input.ts
import { atom } from "recoil";

export const inputState = atom({
  key: 'input',
  default: '',
});
  useEffect(() => {
    switch (tasksLoadable.state) {
      case 'hasValue': {
        const tasks = tasksLoadable.contents.filter((task: TaskEntityObject) => {
          return task.content.includes(input);
        });
        setTasks(tasks);
        break;
      }
      case 'hasError':
        throw tasksLoadable.contents;
    }
  }, [tasksLoadable.state, tasksLoadable.contents, input]);

// ...
ahonn commented 1 year ago

I plan to go through your PR and then modify it by the way above, hope you don't mind. Thank you for your contribution.

meain commented 1 year ago

Somehow my brain ignored the use of recoil. My React skills are getting a bit rusty :D. Thanks for the plugin btw.

ahonn commented 1 year ago

For now you can update to the latest version to use this feature.

github-actions[bot] commented 1 year ago

:tada: This PR is included in version 1.12.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: