From 231ff0386c946915bcec332c243f31a66187ae07 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Thu, 13 Aug 2020 20:47:16 -0700 Subject: [PATCH] Fix kill button not showing up when restarting --- .../scripts/components/server/StopOrKillButton.tsx | 2 +- resources/scripts/components/server/events.ts | 10 ++++++++++ resources/scripts/plugins/Websocket.ts | 7 ------- 3 files changed, 11 insertions(+), 8 deletions(-) create mode 100644 resources/scripts/components/server/events.ts diff --git a/resources/scripts/components/server/StopOrKillButton.tsx b/resources/scripts/components/server/StopOrKillButton.tsx index b9daed85b..fc8490655 100644 --- a/resources/scripts/components/server/StopOrKillButton.tsx +++ b/resources/scripts/components/server/StopOrKillButton.tsx @@ -8,7 +8,7 @@ const StopOrKillButton = ({ onPress }: { onPress: (action: PowerAction) => void const status = ServerContext.useStoreState(state => state.status.value); useEffect(() => { - setClicked(state => [ 'stopping' ].indexOf(status) < 0 ? false : state); + setClicked(status === 'stopping'); }, [ status ]); return ( diff --git a/resources/scripts/components/server/events.ts b/resources/scripts/components/server/events.ts new file mode 100644 index 000000000..4f4c35bde --- /dev/null +++ b/resources/scripts/components/server/events.ts @@ -0,0 +1,10 @@ +export enum SocketEvent { + DAEMON_MESSAGE = 'daemon message', + INSTALL_OUTPUT = 'install output', + INSTALL_STARTED = 'install started', + INSTALL_COMPLETED = 'install completed', + CONSOLE_OUTPUT = 'console output', + STATUS = 'status', + STATS = 'stats', + BACKUP_COMPLETED = 'backup completed', +} diff --git a/resources/scripts/plugins/Websocket.ts b/resources/scripts/plugins/Websocket.ts index 0aa13769d..0f8150dcd 100644 --- a/resources/scripts/plugins/Websocket.ts +++ b/resources/scripts/plugins/Websocket.ts @@ -1,13 +1,6 @@ import Sockette from 'sockette'; import { EventEmitter } from 'events'; -export const SOCKET_EVENTS = [ - 'SOCKET_OPEN', - 'SOCKET_RECONNECT', - 'SOCKET_CLOSE', - 'SOCKET_ERROR', -]; - export class Websocket extends EventEmitter { // Timer instance for this socket. private timer: any = null;