Add the F favorite shortcut and the Ctrl+K tag finder

The command palette now searches e621 tags as you type (debounced
/tags.json suggestions with category chips and post counts), lets you
search a tag online, follow/unfollow it inline and open it on e621, and
remembers recent searches in localStorage. New navigation commands cover
Pools, Followed and Similar. On the online detail, F toggles the current
post's favorite.
This commit is contained in:
2026-09-17 19:36:30 -05:00
parent bbb33905c5
commit f74cf323b5
3 changed files with 304 additions and 75 deletions
+15 -1
View File
@@ -16,6 +16,7 @@ import { DetailShell } from "@/features/detail/DetailShell";
import { api, errorMessage } from "@/lib/api";
import { cn } from "@/lib/cn";
import { renderDText } from "@/lib/dtext";
import { isTypingTarget } from "@/lib/dom";
import {
e621ErrorMessage,
effectiveCredentials,
@@ -118,6 +119,19 @@ export function OnlineDetail({ postId }: { postId: number }) {
const [downloadTaskId, setDownloadTaskId] = useState<string | null>(null);
useEffect(() => {
function handleKeyDown(event: KeyboardEvent) {
if (event.ctrlKey || event.metaKey || event.altKey) return;
if (isTypingTarget(event.target)) return;
if (event.key.toLowerCase() !== "f") return;
if (!post || !credentials?.configured || favoriteMutation.isPending) return;
event.preventDefault();
favoriteMutation.mutate(!post.is_favorited);
}
window.addEventListener("keydown", handleKeyDown);
return () => window.removeEventListener("keydown", handleKeyDown);
}, [post, credentials, favoriteMutation]);
const downloadMutation = useMutation({
mutationFn: (target: NonNullable<typeof post>) =>
api<DownloadTask>("/api/online/downloads/", {
@@ -234,7 +248,7 @@ export function OnlineDetail({ postId }: { postId: number }) {
onClick={() => favoriteMutation.mutate(!post.is_favorited)}
title={
credentials?.configured
? undefined
? "Toggle favorite (F)"
: "Add e621 credentials in Account to favorite posts"
}
>