From 4cf80595ad61107a4edb2041e63983329f23ccb7 Mon Sep 17 00:00:00 2001 From: AAGaming Date: Sun, 28 Jul 2024 18:19:55 -0400 Subject: feat(toaster):add support for dismissing toasts and new indicator --- frontend/src/components/DeckyIcon.tsx | 2 +- frontend/src/components/Toast.tsx | 39 ++++++++++------------ .../components/settings/pages/testing/index.tsx | 3 +- 3 files changed, 21 insertions(+), 23 deletions(-) (limited to 'frontend/src/components') diff --git a/frontend/src/components/DeckyIcon.tsx b/frontend/src/components/DeckyIcon.tsx index fce249e3..85cc2ad7 100644 --- a/frontend/src/components/DeckyIcon.tsx +++ b/frontend/src/components/DeckyIcon.tsx @@ -1,7 +1,7 @@ import { FC, SVGAttributes } from 'react'; const DeckyIcon: FC> = (props) => ( - + m.ShortTemplate) || {}; // These are memoized as they like to randomly rerender -const GamepadUIPopupToast: FC = memo(({ toast }) => { +const GamepadUIPopupToast: FC> = memo(({ toast }) => { return (
= memo(({ toast }) => { ); }); -const GamepadUIQAMToast: FC = memo(({ toast }) => { +const GamepadUIQAMToast: FC = memo(({ toast, newIndicator }) => { // The fields aren't mismatched, the logic for these is just a bit weird. return ( { - Navigation.CloseSideMenus(); toast.onClick?.(); + Navigation.CloseSideMenus(); }} className={joinClassNames( templateClasses.StandardTemplateContainer, @@ -65,11 +65,7 @@ const GamepadUIQAMToast: FC = memo(({ toast }) => {
{toast.icon &&
{toast.icon}
} -
- {toast.header || ( - - )} -
+ {toast.title &&
{toast.title}
} {/* timestamp should always be defined by toaster */} {/* TODO check how valve does this */} {toast.timestamp && ( @@ -78,29 +74,30 @@ const GamepadUIQAMToast: FC = memo(({ toast }) => {
)}
-
- {toast.fullTemplateTitle || toast.title} -
-
{toast.body}
+ {toast.body &&
{toast.body}
} + {toast.subtext &&
{toast.subtext}
}
- {/* TODO support NewIndicator */} - {/*
- -
*/} + {newIndicator && ( +
+ + + +
+ )} ); }); -export const ToastRenderer: FC = memo(({ toast, location }) => { +export const ToastRenderer: FC = memo(({ toast, location, newIndicator }) => { switch (location) { default: - logger.warn(`Toast UI not implemented for location ${location}! Falling back to GamepadUIPopupToast.`); + logger.warn(`Toast UI not implemented for location ${location}! Falling back to GamepadUIQAMToast.`); + return ; case ToastLocation.GAMEPADUI_POPUP: return ; case ToastLocation.GAMEPADUI_QAM: - return ; + return ; } }); diff --git a/frontend/src/components/settings/pages/testing/index.tsx b/frontend/src/components/settings/pages/testing/index.tsx index 6f52afe3..8f02c207 100644 --- a/frontend/src/components/settings/pages/testing/index.tsx +++ b/frontend/src/components/settings/pages/testing/index.tsx @@ -91,13 +91,14 @@ export default function TestingVersionList() { { - DeckyPluginLoader.toaster.toast({ + const downloadToast = DeckyPluginLoader.toaster.toast({ title: t('Testing.start_download_toast', { id: version.id }), body: null, icon: , }); try { await downloadTestingVersion(version.id, version.head_sha); + downloadToast.dismiss(); } catch (e) { if (e instanceof Error) { DeckyPluginLoader.toaster.toast({ -- cgit v1.2.3