From acac0f40446db378bf184580bc29d025f3acb66a Mon Sep 17 00:00:00 2001 From: Jeremie Pardou-Piquemal <571533+jrmi@users.noreply.github.com> Date: Fri, 12 Mar 2021 16:57:12 +0100 Subject: [PATCH] Remove load game button for non master --- src/views/NavBar.jsx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/views/NavBar.jsx b/src/views/NavBar.jsx index 6516582..f00468e 100644 --- a/src/views/NavBar.jsx +++ b/src/views/NavBar.jsx @@ -16,6 +16,7 @@ import useBoardConfig from "../components/useBoardConfig"; import { useTranslation } from "react-i18next"; import Brand from "./Brand"; +import { useC2C } from "../hooks/useC2C"; const StyledNavBar = styled.div.attrs(() => ({ className: "nav" }))` position: fixed; @@ -121,6 +122,7 @@ const StyledNavBar = styled.div.attrs(() => ({ className: "nav" }))` const NavBar = ({ editMode }) => { const { t, i18n } = useTranslation(); + const [, , isMaster] = useC2C(); const [showLoadGameModal, setShowLoadGameModal] = React.useState(false); const [showSaveGameModal, setShowSaveGameModal] = React.useState(false); const [showHelpModal, setShowHelpModal] = React.useState(false); @@ -147,12 +149,14 @@ const NavBar = ({ editMode }) => {
{!editMode && }
- setShowLoadGameModal((prev) => !prev)} - alt={t("Load")} - title={t("Load game")} - icon={"upload-to-cloud"} - /> + {(isMaster || editMode) && ( + setShowLoadGameModal((prev) => !prev)} + alt={t("Load")} + title={t("Load game")} + icon={"upload-to-cloud"} + /> + )} setShowSaveGameModal((prev) => !prev)} alt={t("Save")}