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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user