A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
fix: topic isn't updated on creating shortcut
thecodrre0b9ef20c963
diff --git a/apps/web/src/components/topic/index.js b/apps/web/src/components/topic/index.jsindex 8735e47b0..05d952d81 100644--- a/apps/web/src/components/topic/index.js+++ b/apps/web/src/components/topic/index.js@@ -67,4 +67,9 @@ function Topic({ item, index, onClick }) {/>);}-export default Topic;+export default React.memo(Topic, (prev, next) => {+ return (+ prev?.item?.title === next?.item?.title &&+ prev?.item?.totalNotes === next?.item?.totalNotes+ );+});diff --git a/apps/web/src/stores/app-store.js b/apps/web/src/stores/app-store.jsindex ace6ec8f4..e3352058e 100644--- a/apps/web/src/stores/app-store.js+++ b/apps/web/src/stores/app-store.js@@ -80,21 +80,16 @@ class AppStore extends BaseStore {pinItemToMenu = async (item) => {if (db.settings.isPinned(item.id)) {- this.set((state) => {- const index = state.menuPins.findIndex((i) => i.id === item.id);- if (index >= -1) {- state.menuPins.splice(index, 1);- }- });await db.settings.unpin(item.id);- showToast("success", `Shortcut created!`);+ this.refreshMenuPins();+ showToast("success", `Shortcut removed!`);} else {- this.set((state) => state.menuPins.push(item));await db.settings.pin(item.type, {id: item.id,notebookId: item.notebookId,});- showToast("success", `Shortcut removed!`);+ this.refreshMenuPins();+ showToast("success", `Shortcut created!`);}// refresh the respective listdiff --git a/apps/web/src/stores/notebook-store.js b/apps/web/src/stores/notebook-store.jsindex 9f375edf2..d37be7cae 100644--- a/apps/web/src/stores/notebook-store.js+++ b/apps/web/src/stores/notebook-store.js@@ -1,6 +1,7 @@import { db } from "../common/index";import createStore from "../common/store";import { store as trashStore } from "./trash-store";+import { store as appStore } from "./app-store";import BaseStore from "./index";import { showToast } from "../utils/toast";@@ -25,6 +26,7 @@ class NotebookStore extends BaseStore {this.set((state) => {state.notebooks.splice(index, 1);trashStore.refresh();+ appStore.refreshMenuPins();});};@@ -39,7 +41,9 @@ class NotebookStore extends BaseStore {setSelectedNotebookTopics = (id) => {this.set((state) => {- state.selectedNotebookTopics = db.notebooks.notebook(id).topics.all;+ state.selectedNotebookTopics = db.notebooks+ .notebook(id)+ .topics.all.slice();state.selectedNotebookId = id;});};diff --git a/apps/web/src/views/topics.js b/apps/web/src/views/topics.jsindex 3406d59d5..5580a6c14 100644--- a/apps/web/src/views/topics.js+++ b/apps/web/src/views/topics.js@@ -1,4 +1,4 @@-import React, { useState, useEffect } from "react";+import React, { useEffect } from "react";import { Flex } from "rebass";import ListContainer from "../components/list-container";import { useStore as useNbStore } from "../stores/notebook-store";@@ -14,11 +14,6 @@ function Topics(props) {(store) => store.selectedNotebookTopics);- const [topics, setTopics] = useState([]);- useEffect(() => {- setTopics(selectedNotebookTopics);- }, [selectedNotebookTopics]);-useEffect(() => {setSelectedNotebookTopics(notebookId);}, [setSelectedNotebookTopics, notebookId]);@@ -27,7 +22,7 @@ function Topics(props) {<><ListContainertype="topics"- items={topics}+ items={selectedNotebookTopics}context={{ notebookId }}placeholder={Flex}button={{