mirror of
https://github.com/SteamDeckHomebrew/decky-loader.git
synced 2026-07-11 11:01:58 +00:00
Move to using deckyState
This commit is contained in:
@@ -66,6 +66,7 @@ export class DeckyState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface DeckyStateContext extends PublicDeckyState {
|
interface DeckyStateContext extends PublicDeckyState {
|
||||||
|
setIsLoaderUpdating(hasUpdate: boolean): void;
|
||||||
setActivePlugin(name: string): void;
|
setActivePlugin(name: string): void;
|
||||||
closeActivePlugin(): void;
|
closeActivePlugin(): void;
|
||||||
}
|
}
|
||||||
@@ -91,11 +92,14 @@ export const DeckyStateContextProvider: FC<Props> = ({ children, deckyState }) =
|
|||||||
return () => deckyState.eventBus.removeEventListener('update', onUpdate);
|
return () => deckyState.eventBus.removeEventListener('update', onUpdate);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const setIsLoaderUpdating = (hasUpdate: boolean) => deckyState.setIsLoaderUpdating(hasUpdate);
|
||||||
const setActivePlugin = (name: string) => deckyState.setActivePlugin(name);
|
const setActivePlugin = (name: string) => deckyState.setActivePlugin(name);
|
||||||
const closeActivePlugin = () => deckyState.closeActivePlugin();
|
const closeActivePlugin = () => deckyState.closeActivePlugin();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DeckyStateContext.Provider value={{ ...publicDeckyState, setActivePlugin, closeActivePlugin }}>
|
<DeckyStateContext.Provider
|
||||||
|
value={{ ...publicDeckyState, setIsLoaderUpdating, setActivePlugin, closeActivePlugin }}
|
||||||
|
>
|
||||||
{children}
|
{children}
|
||||||
</DeckyStateContext.Provider>
|
</DeckyStateContext.Provider>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -3,13 +3,14 @@ import { useEffect, useState } from 'react';
|
|||||||
import { FaArrowDown } from 'react-icons/fa';
|
import { FaArrowDown } from 'react-icons/fa';
|
||||||
|
|
||||||
import { VerInfo, callUpdaterMethod, finishUpdate } from '../../../../updater';
|
import { VerInfo, callUpdaterMethod, finishUpdate } from '../../../../updater';
|
||||||
|
import { useDeckyState } from '../../../DeckyState';
|
||||||
|
|
||||||
export default function UpdaterSettings() {
|
export default function UpdaterSettings() {
|
||||||
const [versionInfo, setVersionInfo] = useState<VerInfo | null>(null);
|
const [versionInfo, setVersionInfo] = useState<VerInfo | null>(null);
|
||||||
|
const [checkingForUpdates, setCheckingForUpdates] = useState<boolean>(false);
|
||||||
|
const { isLoaderUpdating, setIsLoaderUpdating } = useDeckyState();
|
||||||
const [updateProgress, setUpdateProgress] = useState<number>(-1);
|
const [updateProgress, setUpdateProgress] = useState<number>(-1);
|
||||||
const [reloading, setReloading] = useState<boolean>(false);
|
const [reloading, setReloading] = useState<boolean>(false);
|
||||||
const [checkingForUpdates, setCheckingForUpdates] = useState<boolean>(false);
|
|
||||||
const [loaderUpdating, setLoaderUpdating] = useState<boolean>(false);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
(async () => {
|
(async () => {
|
||||||
@@ -38,7 +39,7 @@ export default function UpdaterSettings() {
|
|||||||
>
|
>
|
||||||
{updateProgress == -1 ? (
|
{updateProgress == -1 ? (
|
||||||
<DialogButton
|
<DialogButton
|
||||||
disabled={!versionInfo?.updatable || checkingForUpdates || loaderUpdating}
|
disabled={!versionInfo?.updatable || checkingForUpdates || isLoaderUpdating}
|
||||||
onClick={
|
onClick={
|
||||||
!versionInfo?.remote || versionInfo?.remote?.tag_name == versionInfo?.current
|
!versionInfo?.remote || versionInfo?.remote?.tag_name == versionInfo?.current
|
||||||
? async () => {
|
? async () => {
|
||||||
@@ -51,12 +52,12 @@ export default function UpdaterSettings() {
|
|||||||
window.DeckyUpdater = {
|
window.DeckyUpdater = {
|
||||||
updateProgress: (i) => {
|
updateProgress: (i) => {
|
||||||
setUpdateProgress(i);
|
setUpdateProgress(i);
|
||||||
setLoaderUpdating(true);
|
setIsLoaderUpdating(true);
|
||||||
},
|
},
|
||||||
finish: async () => {
|
finish: async () => {
|
||||||
setUpdateProgress(0);
|
setUpdateProgress(0);
|
||||||
setReloading(true);
|
setReloading(true);
|
||||||
setLoaderUpdating(false);
|
setIsLoaderUpdating(false);
|
||||||
await finishUpdate();
|
await finishUpdate();
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user