mirror of
https://github.com/SteamDeckHomebrew/decky-loader.git
synced 2026-06-17 08:47:49 +00:00
35f6f041c1
* git no work so manually uploading files :( * argh i wish git was working * ok next time i'll make git work * Update updater.py * git please work next time this took ages without you * fix me locales * Update updater.py * Update en-US.json * Update updater.py * Update updater.py * i wish my python LSP stuff was working * fix it * Update updater.py * Update updater.py * Only show testing branch as an option if it is already selected * Initial implementation for fetching the open PRs. Still need testing and a token to complete this. * Wrong filter capitalization * Fix a couple of typos in the python backend updater. * Fix typos pt 3 * This should be the last one * Prepend the PR version number with PR- to make it clearer that's the PR number. * Update prettier to the latest version otherwise it will never be happy with the formatting. * fix merge mistake * fix pyright errors & type hint most new code * fix strict pyright errors... * not sure why my local linter didn't catch this * Reimplement the logic between PR and artifact build to limit API calls * Fix pyright errors * use nightly.link for downloads * remove accidental dollar sign * fix various logical errors. the code actually works now. * set branch to testing when user downloads a testing version --------- Co-authored-by: Marco Rodolfi <marco.rodolfi@tuta.io>
58 lines
1.7 KiB
TypeScript
58 lines
1.7 KiB
TypeScript
import { ToastData, joinClassNames } from 'decky-frontend-lib';
|
|
import { FC, useEffect, useState } from 'react';
|
|
import { ReactElement } from 'react-markdown/lib/react-markdown';
|
|
|
|
import { useDeckyToasterState } from './DeckyToasterState';
|
|
import Toast, { toastClasses } from './Toast';
|
|
|
|
interface DeckyToasterProps {}
|
|
|
|
interface RenderedToast {
|
|
component: ReactElement;
|
|
data: ToastData;
|
|
}
|
|
|
|
const DeckyToaster: FC<DeckyToasterProps> = () => {
|
|
const { toasts, removeToast } = useDeckyToasterState();
|
|
const [renderedToast, setRenderedToast] = useState<RenderedToast | null>(null);
|
|
console.log(toasts);
|
|
if (toasts.size > 0) {
|
|
const [activeToast] = toasts;
|
|
if (!renderedToast || activeToast != renderedToast.data) {
|
|
// TODO play toast sound
|
|
console.log('rendering toast', activeToast);
|
|
setRenderedToast({ component: <Toast key={Math.random()} toast={activeToast} />, data: activeToast });
|
|
}
|
|
} else {
|
|
if (renderedToast) setRenderedToast(null);
|
|
}
|
|
useEffect(() => {
|
|
// not actually node but TS is shit
|
|
let interval: NodeJS.Timer | null;
|
|
if (renderedToast) {
|
|
interval = setTimeout(
|
|
() => {
|
|
interval = null;
|
|
console.log('clear toast', renderedToast.data);
|
|
removeToast(renderedToast.data);
|
|
},
|
|
(renderedToast.data.duration || 5e3) + 1000,
|
|
);
|
|
console.log('set int', interval);
|
|
}
|
|
return () => {
|
|
if (interval) {
|
|
console.log('clearing int', interval);
|
|
clearTimeout(interval);
|
|
}
|
|
};
|
|
}, [renderedToast]);
|
|
return (
|
|
<div className={joinClassNames('deckyToaster', toastClasses.ToastPlaceholder)}>
|
|
{renderedToast && renderedToast.component}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default DeckyToaster;
|