fix backup ordering, undo bleed across boards, close flush, due dates
drops the unused announce hook, three unimported ui components, fadeSlideDown, restoreFromBackup and the close-all-modals event, plus the shell plugin from npm and cargo
This commit is contained in:
+8
-5
@@ -13,7 +13,6 @@ import { SettingsDialog } from "@/components/settings/SettingsDialog";
|
||||
import { ToastContainer } from "@/components/toast/ToastContainer";
|
||||
import { ShortcutHelpModal } from "@/components/shortcuts/ShortcutHelpModal";
|
||||
import { useKeyboardShortcuts } from "@/hooks/useKeyboardShortcuts";
|
||||
import { useAnnounceStore } from "@/hooks/useAnnounce";
|
||||
|
||||
export default function App() {
|
||||
const initialized = useAppStore((s) => s.initialized);
|
||||
@@ -21,7 +20,6 @@ export default function App() {
|
||||
const view = useAppStore((s) => s.view);
|
||||
const reduceMotion = useAppStore((s) => s.settings.reduceMotion);
|
||||
const boardTitle = useBoardStore((s) => s.board?.title);
|
||||
const announcement = useAnnounceStore((s) => s.message);
|
||||
|
||||
const [settingsOpen, setSettingsOpen] = useState(false);
|
||||
const [shortcutHelpOpen, setShortcutHelpOpen] = useState(false);
|
||||
@@ -49,8 +47,16 @@ export default function App() {
|
||||
useBoardStore.getState().closeBoard();
|
||||
}
|
||||
window.addEventListener("beforeunload", handleBeforeUnload);
|
||||
|
||||
// The title bar close button skips beforeunload on some platforms
|
||||
const appWindow = getCurrentWindow();
|
||||
const unlistenClose = appWindow.onCloseRequested(() => {
|
||||
useBoardStore.getState().closeBoard();
|
||||
});
|
||||
|
||||
return () => {
|
||||
window.removeEventListener("beforeunload", handleBeforeUnload);
|
||||
unlistenClose.then((fn) => fn());
|
||||
};
|
||||
}, []);
|
||||
|
||||
@@ -136,9 +142,6 @@ export default function App() {
|
||||
|
||||
return (
|
||||
<MotionConfig reducedMotion={reduceMotion ? "always" : "user"}>
|
||||
<div aria-live="assertive" aria-atomic="true" className="sr-only">
|
||||
{announcement}
|
||||
</div>
|
||||
<AppShell>
|
||||
<AnimatePresence mode="wait">
|
||||
{view.type === "board-list" ? (
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import React, { useState, useRef, useEffect, useCallback } from "react";
|
||||
import { Plus } from "lucide-react";
|
||||
import { parse } from "date-fns";
|
||||
import { AnimatePresence, motion } from "framer-motion";
|
||||
import { OverlayScrollbarsComponent, type OverlayScrollbarsComponentRef } from "overlayscrollbars-react";
|
||||
import { staggerContainer } from "@/lib/motion";
|
||||
@@ -96,19 +97,18 @@ export function BoardView() {
|
||||
if (filters.dueDate !== "all") {
|
||||
const now = new Date();
|
||||
const today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
||||
if (filters.dueDate === "none" && card.dueDate != null) return false;
|
||||
if (filters.dueDate === "overdue" && (!card.dueDate || new Date(card.dueDate) >= today)) return false;
|
||||
// dueDate is 'yyyy-MM-dd', which new Date() reads as UTC midnight
|
||||
const due = card.dueDate ? parse(card.dueDate, "yyyy-MM-dd", now) : null;
|
||||
if (filters.dueDate === "none" && due != null) return false;
|
||||
if (filters.dueDate === "overdue" && (!due || due >= today)) return false;
|
||||
if (filters.dueDate === "today") {
|
||||
if (!card.dueDate) return false;
|
||||
const d = new Date(card.dueDate);
|
||||
if (d.toDateString() !== today.toDateString()) return false;
|
||||
if (!due || due.toDateString() !== today.toDateString()) return false;
|
||||
}
|
||||
if (filters.dueDate === "week") {
|
||||
if (!card.dueDate) return false;
|
||||
const d = new Date(card.dueDate);
|
||||
if (!due) return false;
|
||||
const weekEnd = new Date(today);
|
||||
weekEnd.setDate(weekEnd.getDate() + 7);
|
||||
if (d < today || d > weekEnd) return false;
|
||||
if (due < today || due > weekEnd) return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useState, useRef, useEffect } from "react";
|
||||
import { createPortal } from "react-dom";
|
||||
import { format } from "date-fns";
|
||||
import { format, parse } from "date-fns";
|
||||
import { motion, useReducedMotion, AnimatePresence } from "framer-motion";
|
||||
import { fadeSlideUp, springs } from "@/lib/motion";
|
||||
import { useSortable } from "@dnd-kit/sortable";
|
||||
@@ -26,10 +26,10 @@ import { useBoardStore } from "@/stores/board-store";
|
||||
|
||||
function getDueDateStatus(dueDate: string | null): { color: string; bgColor: string; label: string } | null {
|
||||
if (!dueDate) return null;
|
||||
const date = new Date(dueDate);
|
||||
const now = new Date();
|
||||
const today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
||||
const dueDay = new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
||||
// dueDate is 'yyyy-MM-dd', which new Date() reads as UTC midnight
|
||||
const dueDay = parse(dueDate, "yyyy-MM-dd", now);
|
||||
const diffDays = Math.ceil((dueDay.getTime() - today.getTime()) / (1000 * 60 * 60 * 24));
|
||||
|
||||
if (diffDays < 0) {
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
import * as React from "react"
|
||||
import { cva, type VariantProps } from "class-variance-authority"
|
||||
import { Slot } from "radix-ui"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
const badgeVariants = cva(
|
||||
"inline-flex items-center justify-center rounded-full border border-transparent px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default: "bg-primary text-primary-foreground [a&]:hover:bg-primary/90",
|
||||
secondary:
|
||||
"bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",
|
||||
destructive:
|
||||
"bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
|
||||
outline:
|
||||
"border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
|
||||
ghost: "[a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
|
||||
link: "text-primary underline-offset-4 [a&]:hover:underline",
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
variant: "default",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
function Badge({
|
||||
className,
|
||||
variant = "default",
|
||||
asChild = false,
|
||||
...props
|
||||
}: React.ComponentProps<"span"> &
|
||||
VariantProps<typeof badgeVariants> & { asChild?: boolean }) {
|
||||
const Comp = asChild ? Slot.Root : "span"
|
||||
|
||||
return (
|
||||
<Comp
|
||||
data-slot="badge"
|
||||
data-variant={variant}
|
||||
className={cn(badgeVariants({ variant }), className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export { Badge, badgeVariants }
|
||||
@@ -1,58 +0,0 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import { ScrollArea as ScrollAreaPrimitive } from "radix-ui"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
function ScrollArea({
|
||||
className,
|
||||
children,
|
||||
...props
|
||||
}: React.ComponentProps<typeof ScrollAreaPrimitive.Root>) {
|
||||
return (
|
||||
<ScrollAreaPrimitive.Root
|
||||
data-slot="scroll-area"
|
||||
className={cn("relative", className)}
|
||||
{...props}
|
||||
>
|
||||
<ScrollAreaPrimitive.Viewport
|
||||
data-slot="scroll-area-viewport"
|
||||
className="focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1"
|
||||
>
|
||||
{children}
|
||||
</ScrollAreaPrimitive.Viewport>
|
||||
<ScrollBar />
|
||||
<ScrollAreaPrimitive.Corner />
|
||||
</ScrollAreaPrimitive.Root>
|
||||
)
|
||||
}
|
||||
|
||||
function ScrollBar({
|
||||
className,
|
||||
orientation = "vertical",
|
||||
...props
|
||||
}: React.ComponentProps<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>) {
|
||||
return (
|
||||
<ScrollAreaPrimitive.ScrollAreaScrollbar
|
||||
data-slot="scroll-area-scrollbar"
|
||||
orientation={orientation}
|
||||
className={cn(
|
||||
"flex touch-none p-px transition-colors select-none",
|
||||
orientation === "vertical" &&
|
||||
"h-full w-2.5 border-l border-l-transparent",
|
||||
orientation === "horizontal" &&
|
||||
"h-2.5 flex-col border-t border-t-transparent",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<ScrollAreaPrimitive.ScrollAreaThumb
|
||||
data-slot="scroll-area-thumb"
|
||||
className="bg-border relative flex-1 rounded-full"
|
||||
/>
|
||||
</ScrollAreaPrimitive.ScrollAreaScrollbar>
|
||||
)
|
||||
}
|
||||
|
||||
export { ScrollArea, ScrollBar }
|
||||
@@ -1,18 +0,0 @@
|
||||
import * as React from "react"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
function Textarea({ className, ...props }: React.ComponentProps<"textarea">) {
|
||||
return (
|
||||
<textarea
|
||||
data-slot="textarea"
|
||||
className={cn(
|
||||
"border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export { Textarea }
|
||||
@@ -1,19 +0,0 @@
|
||||
import { create } from "zustand";
|
||||
|
||||
interface AnnounceState {
|
||||
message: string;
|
||||
announce: (text: string) => void;
|
||||
}
|
||||
|
||||
export const useAnnounceStore = create<AnnounceState>((set) => ({
|
||||
message: "",
|
||||
announce: (text) => {
|
||||
// Clear first to ensure re-announcement of identical messages
|
||||
set({ message: "" });
|
||||
requestAnimationFrame(() => set({ message: text }));
|
||||
},
|
||||
}));
|
||||
|
||||
export function useAnnounce() {
|
||||
return useAnnounceStore((s) => s.announce);
|
||||
}
|
||||
@@ -35,13 +35,6 @@ export function useKeyboardShortcuts(): void {
|
||||
return;
|
||||
}
|
||||
|
||||
// Escape: close any open modal/dialog
|
||||
// Note: Radix dialogs handle their own Escape, but this covers custom modals
|
||||
if (e.key === "Escape") {
|
||||
document.dispatchEvent(new CustomEvent("close-all-modals"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.key === "?" || (e.shiftKey && e.key === "/")) {
|
||||
e.preventDefault();
|
||||
document.dispatchEvent(new CustomEvent("open-shortcut-help"));
|
||||
|
||||
@@ -17,12 +17,6 @@ export const fadeSlideUp: Variants = {
|
||||
exit: { opacity: 0, y: -8 },
|
||||
};
|
||||
|
||||
export const fadeSlideDown: Variants = {
|
||||
hidden: { opacity: 0, y: -12 },
|
||||
visible: { opacity: 1, y: 0 },
|
||||
exit: { opacity: 0, y: 8 },
|
||||
};
|
||||
|
||||
export const fadeSlideLeft: Variants = {
|
||||
hidden: { opacity: 0, x: 40 },
|
||||
visible: { opacity: 1, x: 0 },
|
||||
|
||||
+3
-20
@@ -221,24 +221,6 @@ export async function deleteBoard(boardId: string): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Backup restoration
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export async function restoreFromBackup(boardId: string): Promise<Board> {
|
||||
const boardsDir = await getBoardsDir();
|
||||
const backupPath = await boardBackupPath(boardsDir, boardId);
|
||||
|
||||
const raw = await readTextFile(backupPath);
|
||||
const data = JSON.parse(raw);
|
||||
const board = boardSchema.parse(data) as Board;
|
||||
|
||||
// Save the restored board as the current version
|
||||
await saveBoard(board);
|
||||
|
||||
return board;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Search
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -361,10 +343,11 @@ export async function listBackups(boardId: string): Promise<BackupEntry[]> {
|
||||
const raw = await readTextFile(filePath);
|
||||
const data = JSON.parse(raw);
|
||||
const board = boardSchema.parse(data);
|
||||
const isoMatch = entry.name.match(/\d{4}-\d{2}-\d{2}T[\d.]+Z/);
|
||||
// createBackup swaps the colons in the ISO stamp for dashes, so stitch them back
|
||||
const isoMatch = entry.name.match(/(\d{4}-\d{2}-\d{2}T\d{2})-(\d{2})-(\d{2}\.\d+Z)/);
|
||||
backups.push({
|
||||
filename: entry.name,
|
||||
timestamp: isoMatch ? isoMatch[0].replace(/-(?=\d{2}-\d{2}T)/g, "-") : board.updatedAt,
|
||||
timestamp: isoMatch ? `${isoMatch[1]}:${isoMatch[2]}:${isoMatch[3]}` : board.updatedAt,
|
||||
cardCount: Object.keys(board.cards).length,
|
||||
columnCount: board.columns.length,
|
||||
});
|
||||
|
||||
@@ -114,6 +114,8 @@ export const useBoardStore = create<BoardState & BoardActions>()(
|
||||
openBoard: async (boardId: string) => {
|
||||
const board = await loadBoard(boardId);
|
||||
set({ board, saving: false, lastSaved: null });
|
||||
// Drop history carried over from the previous board, and the set above
|
||||
useBoardStore.temporal.getState().clear();
|
||||
},
|
||||
|
||||
closeBoard: () => {
|
||||
|
||||
Reference in New Issue
Block a user