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
web: impl preview for trashed notes Signed-off-by: Muhammad Ali <[email protected]>
alihamuh4c6c42c7943c
diff --git a/apps/web/src/components/trash-item/index.js b/apps/web/src/components/trash-item/index.jsindex d3cbbb6f3..c12db448c 100644--- a/apps/web/src/components/trash-item/index.js+++ b/apps/web/src/components/trash-item/index.js@@ -26,11 +26,16 @@ import TimeAgo from "../time-ago";import { pluralize, toTitleCase } from "../../utils/string";import { showUndoableToast } from "../../common/toasts";import { showToast } from "../../utils/toast";+import { hashNavigate } from "../../navigation";+import { useStore } from "../../stores/note-store";function TrashItem({ item, index, date }) {+ const isOpened = useStore((store) => store.selectedNote === item.id);+return (<ListItemselectable+ isFocused={isOpened}item={item}title={item.title}body={item.headline || item.description}@@ -45,6 +50,9 @@ function TrashItem({ item, index, date }) {</Flex>}menu={{ items: menuItems, extraData: { item } }}+ onClick={() => {+ hashNavigate(`/notes/${item.id}/edit`, { replace: true });+ }}/>);}diff --git a/apps/web/src/stores/editor-store.js b/apps/web/src/stores/editor-store.jsindex 2c55d591d..2d00e92df 100644--- a/apps/web/src/stores/editor-store.js+++ b/apps/web/src/stores/editor-store.js@@ -55,7 +55,8 @@ export const getDefaultSession = (sessionId = Date.now()) => {context: undefined,color: undefined,dateEdited: 0,- attachmentsLength: 0+ attachmentsLength: 0,+ isDeleted: false};};@@ -123,9 +124,10 @@ class EditorStore extends BaseStore {return;}- let note = db.notes.note(noteId);+ const note = db.notes.note(noteId)?.data || db.notes.trashed(noteId);+ const isDeleted = note.type === "trash";+if (!note) return;- note = note.data;noteStore.setSelectedNote(note.id);@@ -144,6 +146,10 @@ class EditorStore extends BaseStore {state: SESSION_STATES.new,attachmentsLength: db.attachments.ofNote(note.id, "all")?.length || 0};+ if (isDeleted) {+ state.session.isDeleted = true;+ state.session.readonly = true;+ }});appStore.setIsEditorOpen(true);};@@ -281,6 +287,7 @@ class EditorStore extends BaseStore {};toggleProperties = (toggleState) => {+ if (this.get().session.isDeleted) return;this.set((state) =>(state.arePropertiesVisible =diff --git a/packages/core/collections/notes.js b/packages/core/collections/notes.jsindex dd2c58ac6..adf84c93d 100644--- a/packages/core/collections/notes.js+++ b/packages/core/collections/notes.js@@ -39,6 +39,10 @@ export default class Notes extends Collection {this.topicReferences.rebuild();}+ trashed(id) {+ return this.raw.find((item) => item.dateDeleted > 0 && item.id === id);+ }+async merge(remoteNote) {if (!remoteNote) return;