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: favorites not being unfavorited
thecodrr255085efb87a
diff --git a/apps/web/src/stores/note-store.js b/apps/web/src/stores/note-store.jsindex 938c8f8b2..773f42f1e 100644--- a/apps/web/src/stores/note-store.js+++ b/apps/web/src/stores/note-store.js@@ -6,7 +6,7 @@ const LIST_TYPES = {fav: "favorites"};-function noteStore(set) {+function noteStore(set, get) {return {notes: {items: [],@@ -46,13 +46,14 @@ function noteStore(set) {favorite: async function(note, index) {await db.notes.note(note).favorite();set(state => {- if (index < 0) {- index = state.notes.findIndex(n => n.id === note.id);+ if (index < 0 || !index) {+ index = state.notes.items.findIndex(n => n.id === note.id);if (index < 0) return;}+ console.log(index, state.notes.items[index]);state.notes.items[index].favorite = !note.favorite;- state.initList("favorites");});+ get().refreshList(LIST_TYPES.fav);}};}diff --git a/apps/web/src/views/Favorites.js b/apps/web/src/views/Favorites.jsindex 0aa9e5e50..a04fc8d3a 100644--- a/apps/web/src/views/Favorites.js+++ b/apps/web/src/views/Favorites.js@@ -1,7 +1,7 @@import React, { useEffect } from "react";-import { ev } from "../common";import ListView from "../components/listview";import { useStore, store, LIST_TYPES } from "../stores/note-store";+import { useStore as useEditorStore } from "../stores/editor-store";const dropdownRefs = [];const menuItems = item => [{@@ -13,6 +13,7 @@ const menuItems = item => [function Favorites() {useEffect(() => store.getState().refreshList(LIST_TYPES.fav), []);const items = useStore(store => store.favorites);+ const openSession = useEditorStore(store => store.openSession);return (<ListViewtype="Favorites"@@ -20,17 +21,11 @@ function Favorites() {menu={{ menuItems, dropdownRefs }}noTypebutton={undefined}- onClick={item => {- if (item.type === "note") {- sendOpenNoteEvent(item);- }+ onClick={async item => {+ await openSession(item);}}/>);}-function sendOpenNoteEvent(note) {- ev.emit("onOpenNote", note);-}-export default Favorites;