Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions electron/board-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ export class BoardStore {
result.push({
id: board.id,
title: board.title,
sessionCount: board.sessionCount,
kind: board.kind,
updatedAt: board.updatedAt,
...(board.archivedAt ? { archivedAt: board.archivedAt } : {}),
Expand Down
30 changes: 24 additions & 6 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1630,18 +1630,36 @@ export default function App() {
boardId: string,
sessionId: string,
): Promise<void> {
if (locked()) return;
if (locked()) throw new Error("正在切换画布");
if (boardRef.current?.id !== boardId) await switchBoard(boardId);
const current = boardRef.current;
if (current?.id !== boardId) return;
if (current?.id !== boardId) throw new Error("无法打开画布");
const target = current.notes.find((note) => note.id === sessionId);
if (!target) return;
if (!target) throw new Error("对话不存在");
openDrawer(sessionId);
const at = target.attachedTo;
if (at) setSelection(at);
if (at?.kind === "node") {
const anchorExists =
at?.kind === "node"
? current.nodes.some((n) => n.id === at.id)
: at?.kind === "relation"
? current.relations.some((r) => r.id === at.id)
: false;
if (at && anchorExists) setSelection(at);
if (at && !anchorExists) {
setSelection(null);
setTimeout(() => flow.fitView({ padding: 0.16, duration: 400 }), 80);
showToast("锚点卡已不在画布上");
}
if (at?.kind === "node" && anchorExists) {
// Let React Flow render the selected board before locating its card.
setTimeout(() => frameFamily(at.id, true), 80);
} else if (at?.kind === "relation" && anchorExists) {
const relation = current.relations.find((r) => r.id === at.id)!;
setTimeout(() => flow.fitView({
nodes: [{ id: relation.source }, { id: relation.target }],
padding: 0.2,
duration: 320,
}), 80);
}
}
async function createBoard(walkthrough = false) {
Expand Down Expand Up @@ -3017,7 +3035,7 @@ export default function App() {
sessions={listSessions(board)}
currentSessionId={drawer?.id}
onOpenSession={(boardId, sessionId) =>
void openSession(boardId, sessionId)
openSession(boardId, sessionId)
}
onNewSession={() => addNote(undefined, { fresh: true })}
/>
Expand Down
1 change: 1 addition & 0 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const preview: AtlasAPI = {
return read().map((b) => ({
id: b.id,
title: b.title,
sessionCount: b.sessionCount,
kind: b.kind,
updatedAt: b.updatedAt,
...(b.archivedAt ? { archivedAt: b.archivedAt } : {}),
Expand Down
Loading
Loading