Fix type issues

This commit is contained in:
Dane Everitt
2021-05-08 10:35:44 -07:00
parent 8a30aae06c
commit 6b0120a249
3 changed files with 20 additions and 13 deletions

View File

@@ -20,6 +20,18 @@ export default () => {
const setServerStatus = ServerContext.useStoreActions(actions => actions.status.setServerStatus);
const { setInstance, setConnectionState } = ServerContext.useStoreActions(actions => actions.socket);
const updateToken = (uuid: string, socket: Websocket) => {
if (updatingToken) return;
updatingToken = true;
getWebsocketToken(uuid)
.then(data => socket.setToken(data.token, true))
.catch(error => console.error(error))
.then(() => {
updatingToken = false;
});
};
const connect = (uuid: string) => {
const socket = new Websocket();
@@ -73,18 +85,6 @@ export default () => {
.catch(error => console.error(error));
};
const updateToken = (uuid: string, socket: Websocket) => {
if (updatingToken) return;
updatingToken = true;
getWebsocketToken(uuid)
.then(data => socket.setToken(data.token, true))
.catch(error => console.error(error))
.then(() => {
updatingToken = false;
});
};
useEffect(() => {
connected && setError('');
}, [ connected ]);