Android back button closes modals and leaves the News set browser

Adds useBackButton, a stack of back-button claimants (last claimed wins)
backed by Tauri's app-plugin back-button event. The listener is only
registered while something has claimed the button, so at the root back
keeps its native leave-the-app behavior.

Claimed by: the click-to-preview modal, DialogFrame (so Suggest cards,
Sample hand and every other dialog), and NewsView while a set's card
list is open. A preview opened from inside a dialog closes first.
This commit is contained in:
2026-10-14 21:12:30 -05:00
parent 5888e07586
commit b39b89be20
3 changed files with 77 additions and 3 deletions

View File

@@ -9,6 +9,7 @@ import {
applyCardCriteria,
useCardCriteria,
} from "../components";
import { useBackButton } from "../backButton";
/** Sets whose release date is still ahead of us, newest-announced first. */
function splitByRelease(sets: SetInfo[]): { upcoming: SetInfo[]; released: SetInfo[] } {
@@ -98,6 +99,10 @@ export function NewsView() {
load(false);
}, [load]);
// Android back from a set's card list returns to the news, like the
// "Back to news" button.
useBackButton(() => setOpenSet(null), !!openSet);
function openSetBrowser(set: SetInfo) {
setOpenSet(set);
setCards(null);