From 8b3f569a09db9daf7748426f916a66591159928f Mon Sep 17 00:00:00 2001 From: AAGaming Date: Sun, 21 Aug 2022 16:41:25 -0400 Subject: Add plugin updater, notification badge, fixes --- frontend/src/components/DeckyState.tsx | 22 +++++++++++++++++++++- 1 file changed, 21 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 cbeeb5b4..6f13a007 100644 --- a/frontend/src/components/DeckyState.tsx +++ b/frontend/src/components/DeckyState.tsx @@ -1,20 +1,30 @@ import { FC, createContext, useContext, useEffect, useState } from 'react'; import { Plugin } from '../plugin'; +import { PluginUpdateMapping } from '../store'; interface PublicDeckyState { plugins: Plugin[]; activePlugin: Plugin | null; + updates: PluginUpdateMapping | null; + hasLoaderUpdate?: boolean; } export class DeckyState { private _plugins: Plugin[] = []; private _activePlugin: Plugin | null = null; + private _updates: PluginUpdateMapping | null = null; + private _hasLoaderUpdate: boolean = false; public eventBus = new EventTarget(); publicState(): PublicDeckyState { - return { plugins: this._plugins, activePlugin: this._activePlugin }; + return { + plugins: this._plugins, + activePlugin: this._activePlugin, + updates: this._updates, + hasLoaderUpdate: this._hasLoaderUpdate, + }; } setPlugins(plugins: Plugin[]) { @@ -32,6 +42,16 @@ export class DeckyState { this.notifyUpdate(); } + setUpdates(updates: PluginUpdateMapping) { + this._updates = updates; + this.notifyUpdate(); + } + + setHasLoaderUpdate(hasUpdate: boolean) { + this._hasLoaderUpdate = hasUpdate; + this.notifyUpdate(); + } + private notifyUpdate() { this.eventBus.dispatchEvent(new Event('update')); } -- cgit v1.2.3