From eb439574becb9a82c283d513a98440d7c8efbafe Mon Sep 17 00:00:00 2001
From: TrainDoctor <traindoctor@protonmail.com>
Date: Thu, 1 Sep 2022 13:46:49 -0700
Subject: Addition of proper branch slection (#168)

* This is a bit better, but branch selection still isn't working -_-

* I'm the king of oversight

* Selecting different branch checks for updates

* Stable doesn't detect old versions, which indicates it doesn't work

* Start adding deckyState for plugin updating

* Few tweaks

* Disable nightly selection

* Update decky-frontend-lib and move useSetting set setting to async
---
 frontend/src/components/DeckyState.tsx | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

(limited to 'frontend/src/components/DeckyState.tsx')

diff --git a/frontend/src/components/DeckyState.tsx b/frontend/src/components/DeckyState.tsx
index 386880e9..283fb118 100644
--- a/frontend/src/components/DeckyState.tsx
+++ b/frontend/src/components/DeckyState.tsx
@@ -2,6 +2,7 @@ import { FC, createContext, useContext, useEffect, useState } from 'react';
 
 import { Plugin } from '../plugin';
 import { PluginUpdateMapping } from '../store';
+import { VerInfo } from '../updater';
 
 interface PublicDeckyState {
   plugins: Plugin[];
@@ -9,6 +10,7 @@ interface PublicDeckyState {
   updates: PluginUpdateMapping | null;
   hasLoaderUpdate?: boolean;
   isLoaderUpdating: boolean;
+  versionInfo: VerInfo | null;
 }
 
 export class DeckyState {
@@ -17,6 +19,7 @@ export class DeckyState {
   private _updates: PluginUpdateMapping | null = null;
   private _hasLoaderUpdate: boolean = false;
   private _isLoaderUpdating: boolean = false;
+  private _versionInfo: VerInfo | null = null;
 
   public eventBus = new EventTarget();
 
@@ -27,9 +30,15 @@ export class DeckyState {
       updates: this._updates,
       hasLoaderUpdate: this._hasLoaderUpdate,
       isLoaderUpdating: this._isLoaderUpdating,
+      versionInfo: this._versionInfo,
     };
   }
 
+  setVersionInfo(versionInfo: VerInfo) {
+    this._versionInfo = versionInfo;
+    this.notifyUpdate();
+  }
+
   setPlugins(plugins: Plugin[]) {
     this._plugins = plugins;
     this.notifyUpdate();
@@ -66,6 +75,7 @@ export class DeckyState {
 }
 
 interface DeckyStateContext extends PublicDeckyState {
+  setVersionInfo(versionInfo: VerInfo): void;
   setIsLoaderUpdating(hasUpdate: boolean): void;
   setActivePlugin(name: string): void;
   closeActivePlugin(): void;
@@ -93,12 +103,13 @@ export const DeckyStateContextProvider: FC<Props> = ({ children, deckyState }) =
   }, []);
 
   const setIsLoaderUpdating = (hasUpdate: boolean) => deckyState.setIsLoaderUpdating(hasUpdate);
+  const setVersionInfo = (versionInfo: VerInfo) => deckyState.setVersionInfo(versionInfo);
   const setActivePlugin = (name: string) => deckyState.setActivePlugin(name);
   const closeActivePlugin = () => deckyState.closeActivePlugin();
 
   return (
     <DeckyStateContext.Provider
-      value={{ ...publicDeckyState, setIsLoaderUpdating, setActivePlugin, closeActivePlugin }}
+      value={{ ...publicDeckyState, setIsLoaderUpdating, setVersionInfo, setActivePlugin, closeActivePlugin }}
     >
       {children}
     </DeckyStateContext.Provider>
-- 
cgit v1.2.3

