address code review findings - data loss, race condition, broken features

This commit is contained in:
2026-02-15 19:33:25 +02:00
parent 0b70ee656f
commit 3369c34675
4 changed files with 38 additions and 14 deletions

View File

@@ -1,6 +1,8 @@
import { FileIcon, X, Plus } from "lucide-react";
import { open } from "@tauri-apps/plugin-dialog";
import { Button } from "@/components/ui/button";
import { useBoardStore } from "@/stores/board-store";
import { copyAttachment } from "@/lib/storage";
import type { Attachment } from "@/types/board";
interface AttachmentSectionProps {
@@ -12,11 +14,29 @@ export function AttachmentSection({
cardId,
attachments,
}: AttachmentSectionProps) {
const addAttachment = useBoardStore((s) => s.addAttachment);
const removeAttachment = useBoardStore((s) => s.removeAttachment);
function handleAdd() {
// Placeholder: Tauri file dialog will be wired in a later task
console.log("Add attachment (file dialog not yet wired)");
async function handleAdd() {
const selected = await open({
multiple: false,
title: "Select attachment",
});
if (!selected) return;
const fileName = selected.split(/[\\/]/).pop() ?? "attachment";
const board = useBoardStore.getState().board;
if (!board) return;
const mode = board.settings.attachmentMode;
if (mode === "copy") {
const destPath = await copyAttachment(board.id, selected, fileName);
addAttachment(cardId, { name: fileName, path: destPath, mode: "copy" });
} else {
addAttachment(cardId, { name: fileName, path: selected, mode: "link" });
}
}
return (