From 414493eed2bea2ceb13c9add216d6f9e7f9c5903 Mon Sep 17 00:00:00 2001 From: marios Date: Sun, 29 Jun 2025 21:36:48 +0300 Subject: Add Decky branch switcher and updater to error boundary (#775) * Add Decky branch switcher and updater to error boundary * Linting fixup * Update DeckyErrorBoundary.tsx Allow for plugins to trigger new behavior. * Lint fixup --- frontend/.prettierrc.js | 2 +- frontend/src/components/DeckyErrorBoundary.tsx | 82 ++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 1 deletion(-) diff --git a/frontend/.prettierrc.js b/frontend/.prettierrc.js index 7a0331c8..df3e6cde 100644 --- a/frontend/.prettierrc.js +++ b/frontend/.prettierrc.js @@ -7,4 +7,4 @@ export default { tabWidth: 2, endOfLine: 'auto', plugins: [importSort], -} \ No newline at end of file +}; diff --git a/frontend/src/components/DeckyErrorBoundary.tsx b/frontend/src/components/DeckyErrorBoundary.tsx index 654db8a0..7a8d2b31 100644 --- a/frontend/src/components/DeckyErrorBoundary.tsx +++ b/frontend/src/components/DeckyErrorBoundary.tsx @@ -4,6 +4,8 @@ import { FunctionComponent, useEffect, useReducer, useState } from 'react'; import { uninstallPlugin } from '../plugin'; import { VerInfo, doRestart, doShutdown } from '../updater'; import { ValveReactErrorInfo, getLikelyErrorSourceFromValveReactError } from '../utils/errors'; +import { useSetting } from '../utils/hooks/useSetting'; +import { UpdateBranch } from './settings/pages/general/BranchSelect'; interface DeckyErrorBoundaryProps { error: ValveReactErrorInfo; @@ -37,6 +39,27 @@ const DeckyErrorBoundary: FunctionComponent = ({ error, if (!shouldReportToValve) DeckyPluginLoader.errorBoundaryHook.temporarilyDisableReporting(); DeckyPluginLoader.updateVersion().then(setVersionInfo); }, []); + + const [selectedBranch, setSelectedBranch] = useSetting('branch', UpdateBranch.Stable); + const [isChecking, setIsChecking] = useState(false); + const [updateProgress, setUpdateProgress] = useState(-1); + const [versionToUpdateTo, setSetVersionToUpdateTo] = useState(''); + + useEffect(() => { + const a = DeckyBackend.addEventListener('updater/update_download_percentage', (percentage) => { + setUpdateProgress(percentage); + }); + + const b = DeckyBackend.addEventListener('updater/finish_download', () => { + setUpdateProgress(-2); + }); + + return () => { + DeckyBackend.removeEventListener('updater/update_download_percentage', a); + DeckyBackend.removeEventListener('updater/finish_download', b); + }; + }, []); + return ( <>