AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.
HTML ai-agentcloudflarecloudflare-d1cloudflare-r2cloudflare-workersdockerelectronevernoteevernote-alternativeknowledge-basemcpnote-takingobsidian-alternativeoffline-firstpersonal-knowledge-basepwaself-hostedsqlitetiptapweb-clipper
Preserve memo list position after delete
yoma53df429d0da7
diff --git a/apps/web/src/components/WorkspaceApp.tsx b/apps/web/src/components/WorkspaceApp.tsxindex 196f62e6..fbd95868 100644--- a/apps/web/src/components/WorkspaceApp.tsx+++ b/apps/web/src/components/WorkspaceApp.tsx@@ -142,6 +142,30 @@ const cacheMemoDetail = (queryClient: QueryClient, memo: MemoDetail, view: MemoVqueryClient.setQueryData(memoDetailQueryKey(memo.id, view), { memo });};+const getAdjacentMemoIdAfterRemoval = (memos: MemoSummary[], removedMemoIds: Set<string>, anchorMemoId: string) => {+ const anchorIndex = memos.findIndex((memo) => memo.id === anchorMemoId);++ if (anchorIndex < 0) {+ return null;+ }++ for (let index = anchorIndex + 1; index < memos.length; index++) {+ const memoId = memos[index]?.id;+ if (memoId && !removedMemoIds.has(memoId)) {+ return memoId;+ }+ }++ for (let index = anchorIndex - 1; index >= 0; index--) {+ const memoId = memos[index]?.id;+ if (memoId && !removedMemoIds.has(memoId)) {+ return memoId;+ }+ }++ return null;+};+const MobileBottomNavButton = ({active = false,icon,@@ -1088,7 +1112,7 @@ export const WorkspaceApp = ({clearMemoSelection();if (selectedMemoId && deletedMemoIds.has(selectedMemoId)) {- setSelectedMemoId(null);+ setSelectedMemoId(getAdjacentMemoIdAfterRemoval(memos, deletedMemoIds, selectedMemoId));setActivePane("memos");}@@ -1106,7 +1130,7 @@ export const WorkspaceApp = ({api.deleteMemo(memoId, { permanent }),onSuccess: async (_data, variables) => {if (selectedMemoId === variables.memoId) {- setSelectedMemoId(null);+ setSelectedMemoId(getAdjacentMemoIdAfterRemoval(memos, new Set([variables.memoId]), variables.memoId));setActivePane("memos");}await Promise.all([