Merge branch 'test/v1.8.1' of https://github.com/mitchemmc/owlbear-rodeo into test/v1.8.1
This commit is contained in:
commit
47d18e9095
23
src/modals/ForceUpdateModal.js
Normal file
23
src/modals/ForceUpdateModal.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import React from "react";
|
||||||
|
import { Box, Label, Text } from "theme-ui";
|
||||||
|
|
||||||
|
import Modal from "../components/Modal";
|
||||||
|
|
||||||
|
function ForceUpdateModal({ isOpen }) {
|
||||||
|
return (
|
||||||
|
<Modal
|
||||||
|
isOpen={isOpen}
|
||||||
|
allowClose={false}
|
||||||
|
style={{ maxWidth: "450px" }}
|
||||||
|
>
|
||||||
|
<Box>
|
||||||
|
<Label py={2}>New Update Available</Label>
|
||||||
|
<Text as="p" mb={2} variant="caption">
|
||||||
|
Please refresh your browser to update to the latest version.
|
||||||
|
</Text>
|
||||||
|
</Box>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ForceUpdateModal;
|
@ -26,7 +26,7 @@ import { logError } from "../helpers/logging";
|
|||||||
* Session Status Event - Status of the session has changed
|
* Session Status Event - Status of the session has changed
|
||||||
*
|
*
|
||||||
* @event Session#status
|
* @event Session#status
|
||||||
* @property {"ready"|"joining"|"joined"|"offline"|"reconnecting"|"auth"} status
|
* @property {"ready"|"joining"|"joined"|"offline"|"reconnecting"|"auth"|"needs_update"} status
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -101,6 +101,7 @@ class Session extends EventEmitter {
|
|||||||
this.socket.on("game_expired", this._handleGameExpired.bind(this));
|
this.socket.on("game_expired", this._handleGameExpired.bind(this));
|
||||||
this.socket.on("disconnect", this._handleSocketDisconnect.bind(this));
|
this.socket.on("disconnect", this._handleSocketDisconnect.bind(this));
|
||||||
this.socket.io.on("reconnect", this._handleSocketReconnect.bind(this));
|
this.socket.io.on("reconnect", this._handleSocketReconnect.bind(this));
|
||||||
|
this.socket.on("force_update", this._handleForceUpdate.bind(this));
|
||||||
|
|
||||||
this.emit("status", "ready");
|
this.emit("status", "ready");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -197,7 +198,7 @@ class Session extends EventEmitter {
|
|||||||
|
|
||||||
this._gameId = gameId;
|
this._gameId = gameId;
|
||||||
this._password = password;
|
this._password = password;
|
||||||
this.socket.emit("join_game", gameId, password);
|
this.socket.emit("join_game", gameId, password, process.env.REACT_APP_VERSION);
|
||||||
this.emit("status", "joining");
|
this.emit("status", "joining");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -418,6 +419,16 @@ class Session extends EventEmitter {
|
|||||||
this.joinGame(this._gameId, this._password);
|
this.joinGame(this._gameId, this._password);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_handleForceUpdate() {
|
||||||
|
/**
|
||||||
|
* Force Update Event - An update has been released
|
||||||
|
*
|
||||||
|
* @event Session#forceUpdate
|
||||||
|
*/
|
||||||
|
this.socket.disconnect();
|
||||||
|
this.emit("status", "needs_update");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Session;
|
export default Session;
|
||||||
|
@ -11,6 +11,7 @@ import MapLoadingOverlay from "../components/map/MapLoadingOverlay";
|
|||||||
|
|
||||||
import AuthModal from "../modals/AuthModal";
|
import AuthModal from "../modals/AuthModal";
|
||||||
import GameExpiredModal from "../modals/GameExpiredModal";
|
import GameExpiredModal from "../modals/GameExpiredModal";
|
||||||
|
import ForceUpdateModal from "../modals/ForceUpdateModal";
|
||||||
|
|
||||||
import { useAuth } from "../contexts/AuthContext";
|
import { useAuth } from "../contexts/AuthContext";
|
||||||
import { MapStageProvider } from "../contexts/MapStageContext";
|
import { MapStageProvider } from "../contexts/MapStageContext";
|
||||||
@ -83,6 +84,7 @@ function Game() {
|
|||||||
};
|
};
|
||||||
}, [session]);
|
}, [session]);
|
||||||
|
|
||||||
|
|
||||||
// Join game
|
// Join game
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (sessionStatus === "ready" && databaseStatus !== "loading") {
|
if (sessionStatus === "ready" && databaseStatus !== "loading") {
|
||||||
@ -137,6 +139,9 @@ function Game() {
|
|||||||
isOpen={gameExpired}
|
isOpen={gameExpired}
|
||||||
onRequestClose={() => setGameExpired(false)}
|
onRequestClose={() => setGameExpired(false)}
|
||||||
/>
|
/>
|
||||||
|
<ForceUpdateModal
|
||||||
|
isOpen={sessionStatus === "needs_update"}
|
||||||
|
/>
|
||||||
{!sessionStatus && <LoadingOverlay />}
|
{!sessionStatus && <LoadingOverlay />}
|
||||||
<MapLoadingOverlay />
|
<MapLoadingOverlay />
|
||||||
</MapStageProvider>
|
</MapStageProvider>
|
||||||
|
Loading…
Reference in New Issue
Block a user