Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

feat: implement notebooks search

thecodrr1ab386d52c88
diff --git a/apps/web/src/views/Notebooks.js b/apps/web/src/views/Notebooks.js
index 17bb58391..038c6ee31 100644
--- a/apps/web/src/views/Notebooks.js
+++ b/apps/web/src/views/Notebooks.js
@@ -7,39 +7,45 @@ import ListContainer from "../components/list-container";
import { useStore, store } from "../stores/notebook-store";
import NotebooksPlaceholder from "../components/placeholders/notebooks-placeholder";
+const NotebookItem = props => (index, item) => (
+ <Notebook
+ index={index}
+ item={item}
+ onClick={() => {
+ props.navigator.navigate("topics", {
+ title: item.title,
+ topics: item.topics,
+ notebook: item
+ });
+ }}
+ onTopicClick={(notebook, topic) =>
+ props.navigator.navigate("notes", {
+ title: notebook.title,
+ subtitle: topic.title,
+ notes: db.notebooks.notebook(notebook.id).topics.topic(topic.title).all
+ })
+ }
+ />
+);
+
const Notebooks = props => {
const [open, setOpen] = useState(false);
useEffect(() => store.getState().refresh(), []);
const notebooks = useStore(state => state.notebooks);
const add = useStore(state => state.add);
-
return (
<>
<ListContainer
+ searchPlaceholder="Search your notebooks"
+ term={props.term}
itemsLength={notebooks.length}
placeholder={NotebooksPlaceholder}
- item={index => (
- <Notebook
- index={index}
- item={notebooks[index]}
- onClick={() => {
- props.navigator.navigate("topics", {
- title: notebooks[index].title,
- topics: notebooks[index].topics,
- notebook: notebooks[index]
- });
- }}
- onTopicClick={(notebook, topic) =>
- props.navigator.navigate("notes", {
- title: notebook.title,
- subtitle: topic.title,
- notes: db.notebooks
- .notebook(notebook.id)
- .topics.topic(topic.title).all
- })
- }
- />
- )}
+ searchParams={{
+ items: notebooks,
+ type: "notebooks",
+ item: NotebookItem(props)
+ }}
+ item={index => NotebookItem(props)(index, notebooks[index])}
button={{
content: "Create a notebook",
onClick: async () => {
@@ -61,14 +67,14 @@ const Notebooks = props => {
);
};
-const NotebooksContainer = () => {
+const NotebooksContainer = props => {
useEffect(() => {
const NotebookNavigator = require("../navigation/navigators/nbnavigator")
.default;
- if (!NotebookNavigator.restore()) {
+ if (!NotebookNavigator.restore(props)) {
NotebookNavigator.navigate("notebooks");
}
- }, []);
+ }, [props]);
return (
<Flex
className="NotebookNavigator"