From 216e2c8cd453bf2eac14265413069ba203ded39b Mon Sep 17 00:00:00 2001
From: David Snyder <45735850+GypsyDangerous@users.noreply.github.com>
Date: Tue, 20 Oct 2020 09:43:37 -0400
Subject: [PATCH] Revert "Intuitive (#34)"
This reverts commit 762b770a161f8a9b65a35c064524d06f22a55787.
---
src/components/DashBoard/Dashboard.js | 41 ++--------
.../Plugins/CustomCommands/CreateCommand.js | 2 +-
.../CustomCommands/CreateRoleCommand.js | 1 +
.../CustomCommands/CreateTextCommand.js | 1 +
.../Plugins/CustomCommands/CustomCommands.js | 6 +-
.../DashBoard/Discord/Plugins/Leveling.js | 38 ++--------
.../DashBoard/Discord/Plugins/Logging.js | 74 ++++++-------------
.../DashBoard/Discord/Plugins/PluginCard.js | 3 +-
.../DashBoard/Discord/Plugins/PluginCard.scss | 5 --
.../DashBoard/Discord/Plugins/PluginHome.js | 5 +-
.../Discord/Plugins/Roles/ManagerItem.js | 2 +-
.../DashBoard/Discord/Plugins/Roles/Roles.js | 3 +-
src/components/DashBoard/Settings/Setting.js | 2 +-
src/contexts/DiscordContext.js | 26 +++----
14 files changed, 56 insertions(+), 153 deletions(-)
diff --git a/src/components/DashBoard/Dashboard.js b/src/components/DashBoard/Dashboard.js
index 5c2678b..b3b7bff 100644
--- a/src/components/DashBoard/Dashboard.js
+++ b/src/components/DashBoard/Dashboard.js
@@ -10,9 +10,6 @@ import AccountSettings from "./Account/Account";
import plugins from "./Discord/Plugins/plugins.json";
import { DiscordContextProvider, DiscordContext } from "../../contexts/DiscordContext";
import { useMediaQuery } from "@material-ui/core";
-import Snackbar from "@material-ui/core/Snackbar";
-import IconButton from "@material-ui/core/IconButton";
-import CloseIcon from "@material-ui/icons/Close";
const Dashboard = props => {
const [overlaySettings, setOverlaySettings] = useState();
@@ -21,15 +18,7 @@ const Dashboard = props => {
const { currentUser, dropDownOpen: open } = useContext(AppContext);
const id = firebase.auth.currentUser.uid;
const [discordId, setDiscordId] = useState("");
- const { activePlugins, dashboardOpen, setDashboardOpen } = useContext(DiscordContext);
-
- const handleClose = (event, reason) => {
- if (reason === "clickaway") {
- return;
- }
- setDashboardOpen(false);
- };
-
+ const { activePlugins } = useContext(DiscordContext);
useEffect(() => {
const idRegex = new RegExp("/\\d{17,19}[/\\b]");
const path = props.location.pathname + "/";
@@ -88,13 +77,13 @@ const Dashboard = props => {
.filter(key => activePlugins[key])
.sort(),
[activePlugins]
- );
-
- const showDropdown = useMediaQuery("(min-width: 900px)");
+ );
+
+ const showDropdown = useMediaQuery("(min-width: 900px)")
return (
-
+
App Settings
@@ -104,13 +93,12 @@ const Dashboard = props => {
Discord Settings
- {showDropdown && !!displayPlugins.length && window?.location?.pathname?.includes?.("discord") && (
+ {showDropdown && !!displayPlugins.length && window?.location?.pathname?.includes?.("discord") && (
{displayPlugins.map(key => {
const plugin = plugins.find(plugin => plugin.id === key);
return (
{
-
-
-
-
-
- }
- />
);
diff --git a/src/components/DashBoard/Discord/Plugins/CustomCommands/CreateCommand.js b/src/components/DashBoard/Discord/Plugins/CustomCommands/CreateCommand.js
index 0d4424e..4d62048 100644
--- a/src/components/DashBoard/Discord/Plugins/CustomCommands/CreateCommand.js
+++ b/src/components/DashBoard/Discord/Plugins/CustomCommands/CreateCommand.js
@@ -37,7 +37,7 @@ const FancySwitch = withStyles({
opacity: "1 !important",
},
},
-
+ focusVisible: {},
})(Switch);
const parseSelectValue = value => {
diff --git a/src/components/DashBoard/Discord/Plugins/CustomCommands/CreateRoleCommand.js b/src/components/DashBoard/Discord/Plugins/CustomCommands/CreateRoleCommand.js
index 789b7a5..a2e03ae 100644
--- a/src/components/DashBoard/Discord/Plugins/CustomCommands/CreateRoleCommand.js
+++ b/src/components/DashBoard/Discord/Plugins/CustomCommands/CreateRoleCommand.js
@@ -7,6 +7,7 @@ import RoleItem from "../../../../Shared/RoleItem";
import { CommandContext } from "../../../../../contexts/CommandContext";
const CreateRoleCommand = ({ setCreatingCommand, guild: userConnectedGuildInfo }) => {
+ const { setActivePlugins } = useContext(DiscordContext);
const { roleToGive, setRoleToGive } = useContext(CommandContext);
return (
<>
diff --git a/src/components/DashBoard/Discord/Plugins/CustomCommands/CreateTextCommand.js b/src/components/DashBoard/Discord/Plugins/CustomCommands/CreateTextCommand.js
index 753ff3f..8e9e211 100644
--- a/src/components/DashBoard/Discord/Plugins/CustomCommands/CreateTextCommand.js
+++ b/src/components/DashBoard/Discord/Plugins/CustomCommands/CreateTextCommand.js
@@ -3,6 +3,7 @@ import React, { useContext } from "react";
import { CommandContext } from "../../../../../contexts/CommandContext";
const CreateTextCommand = () => {
+ const { setActivePlugins, userConnectedGuildInfo } = useContext(DiscordContext);
const { response, setResponse } = useContext(CommandContext);
return (
<>
diff --git a/src/components/DashBoard/Discord/Plugins/CustomCommands/CustomCommands.js b/src/components/DashBoard/Discord/Plugins/CustomCommands/CustomCommands.js
index aaa3f8f..c44fa8e 100644
--- a/src/components/DashBoard/Discord/Plugins/CustomCommands/CustomCommands.js
+++ b/src/components/DashBoard/Discord/Plugins/CustomCommands/CustomCommands.js
@@ -10,9 +10,12 @@ import CommandItem from "./CommandItem";
import { CommandContext } from "../../../../../contexts/CommandContext";
const CustomCommands = ({ location, guild: userConnectedGuildInfo }) => {
+ const [loggingChannel, setLoggingChannel] = useState("");
+ const [activeEvents, setActiveEvents] = useState({});
+ const [allEvents, setAllEvents] = useState({});
const [creatingCommand, setCreatingCommand] = useState(false);
const [commands, setCommands] = useState({});
- const { setActivePlugins, setDashboardOpen } = useContext(DiscordContext);
+ const { setActivePlugins } = useContext(DiscordContext);
const guildId = userConnectedGuildInfo?.id;
const {
setName,
@@ -93,7 +96,6 @@ const CustomCommands = ({ location, guild: userConnectedGuildInfo }) => {
});
return newPlugs;
});
- setDashboardOpen(true)
}}
>
Disable
diff --git a/src/components/DashBoard/Discord/Plugins/Leveling.js b/src/components/DashBoard/Discord/Plugins/Leveling.js
index 52e6c6d..cf093a8 100644
--- a/src/components/DashBoard/Discord/Plugins/Leveling.js
+++ b/src/components/DashBoard/Discord/Plugins/Leveling.js
@@ -14,7 +14,7 @@ import { useMediaQuery } from "@material-ui/core";
const ToggleChevron = styled.span`
& > * {
- transition: 0.25s;
+ transition: .25s;
transform: rotate(${props => (!props.closed ? "180deg" : "0deg")});
}
`;
@@ -61,7 +61,7 @@ const Leveling = ({ location, guild: userConnectedGuildInfo }) => {
const [levelUpAnnouncement, setLevelUpAnnouncement] = useState();
const [announcementChannel, setAnnouncementChannel] = useState(false);
const [levelUpMessage, setLevelUpMessage] = useState("Congrats {player}, you leveled up to level {level}!");
- const { setActivePlugins, setDashboardOpen, saveOnType } = useContext(DiscordContext);
+ const { setActivePlugins } = useContext(DiscordContext);
const [ranksClosed, setRanksClosed] = useState(false);
const guildId = userConnectedGuildInfo?.id;
@@ -69,12 +69,7 @@ const Leveling = ({ location, guild: userConnectedGuildInfo }) => {
async e => {
const guildLevelRef = firebase.db.collection("Leveling").doc(guildId);
setLevelUpAnnouncement(e);
- try {
- await guildLevelRef.update({ type: e.value });
- } catch (err) {
- await guildLevelRef.set({ type: e.value });
- }
- setDashboardOpen(true);
+ await guildLevelRef.update({ type: e.value });
},
[guildId]
);
@@ -84,12 +79,7 @@ const Leveling = ({ location, guild: userConnectedGuildInfo }) => {
const guildLevelRef = firebase.db.collection("Leveling").doc(guildId);
const message = e.target.value;
setLevelUpMessage(message);
- try {
- await guildLevelRef.update({ message });
- } catch (err) {
- await guildLevelRef.set({ message });
- }
- saveOnType();
+ await guildLevelRef.update({ message });
},
[guildId]
);
@@ -98,12 +88,7 @@ const Leveling = ({ location, guild: userConnectedGuildInfo }) => {
async e => {
const guildLevelRef = firebase.db.collection("Leveling").doc(guildId);
setAnnouncementChannel(e);
- try {
- guildLevelRef.update({ notifications: e.value });
- } catch (err) {
- guildLevelRef.set({ notifications: e.value });
- }
- setDashboardOpen(true);
+ guildLevelRef.update({ notifications: e.value });
},
[guildId]
);
@@ -140,7 +125,7 @@ const Leveling = ({ location, guild: userConnectedGuildInfo }) => {
})();
}, [location, guildId]);
- const smallScreen = useMediaQuery("(max-width: 500px)");
+ const smallScreen = useMediaQuery("(max-width: 500px)")
return (
@@ -154,25 +139,14 @@ const Leveling = ({ location, guild: userConnectedGuildInfo }) => {
onClick={() => {
setActivePlugins(prev => {
const newPlugs = { ...prev, leveling: false };
-
firebase.db
.collection("DiscordSettings")
.doc(guildId || " ")
.update({
activePlugins: newPlugs,
- })
- .catch(err => {
- firebase.db
- .collection("DiscordSettings")
- .doc(guildId || " ")
- .set({
- activePlugins: newPlugs,
- });
});
-
return newPlugs;
});
- setDashboardOpen(true);
}}
>
Disable
diff --git a/src/components/DashBoard/Discord/Plugins/Logging.js b/src/components/DashBoard/Discord/Plugins/Logging.js
index 43d0e92..b9caa79 100644
--- a/src/components/DashBoard/Discord/Plugins/Logging.js
+++ b/src/components/DashBoard/Discord/Plugins/Logging.js
@@ -4,10 +4,9 @@ import { DiscordContext } from "../../../../contexts/DiscordContext";
import { colorStyles } from "../../../Shared/userUtils";
import Select from "react-select";
import FormControlLabel from "@material-ui/core/FormControlLabel";
-import { Switch, Tooltip } from "@material-ui/core";
+import { Switch } from "@material-ui/core";
import { withStyles } from "@material-ui/core/styles";
import { blueGrey } from "@material-ui/core/colors";
-import InfoTwoToneIcon from "@material-ui/icons/InfoTwoTone";
const FancySwitch = withStyles({
root: {
@@ -35,13 +34,14 @@ const FancySwitch = withStyles({
opacity: "1 !important",
},
},
+ focusVisible: {},
})(Switch);
const Leveling = ({ location, guild: userConnectedGuildInfo }) => {
const [loggingChannel, setLoggingChannel] = useState("");
const [activeEvents, setActiveEvents] = useState({});
const [allEvents, setAllEvents] = useState({});
- const { setActivePlugins, setDashboardOpen } = useContext(DiscordContext);
+ const { setActivePlugins } = useContext(DiscordContext);
const [channelOverrides, setChannelOverrides] = useState({});
const guildId = userConnectedGuildInfo?.id;
@@ -88,9 +88,9 @@ const Leveling = ({ location, guild: userConnectedGuildInfo }) => {
setActiveEvents(active || {});
} else {
try {
- await firebase.db.collection("loggingChannel").doc(guildId).update({});
+ firebase.db.collection("loggingChannel").doc(guildId).update({});
} catch (err) {
- await firebase.db.collection("loggingChannel").doc(guildId).set({});
+ firebase.db.collection("loggingChannel").doc(guildId).set({});
}
}
})();
@@ -102,52 +102,32 @@ const Leveling = ({ location, guild: userConnectedGuildInfo }) => {
}, [location, guildId]);
const handleOverrideSelect = useCallback(
- async (e, category) => {
+ (e, category) => {
setChannelOverrides(prev => ({
...prev,
[category]: e,
}));
- try {
- await firebase.db
- .collection("loggingChannel")
- .doc(guildId)
- .update({
- [`channelOverrides.${category}`]: e?.value || false,
- });
- } catch (err) {
- await firebase.db
- .collection("loggingChannel")
- .doc(guildId)
- .set({
- [`channelOverrides.${category}`]: e?.value || false,
- });
- }
- setDashboardOpen(true);
+ firebase.db
+ .collection("loggingChannel")
+ .doc(guildId)
+ .update({
+ [`channelOverrides.${category}`]: e?.value || false,
+ });
},
[guildId]
);
- const handleEventToggle = useCallback(async (e, id) => {
+ const handleEventToggle = useCallback((e, id) => {
setActiveEvents(prev => ({
...prev,
[id]: e.target.checked,
}));
- try {
- await firebase.db
- .collection("loggingChannel")
- .doc(guildId)
- .update({
- [`activeEvents.${id}`]: e.target.checked,
- });
- } catch (err) {
- await firebase.db
- .collection("loggingChannel")
- .doc(guildId)
- .set({
- [`activeEvents.${id}`]: e.target.checked,
- });
- }
- setDashboardOpen(true);
+ firebase.db
+ .collection("loggingChannel")
+ .doc(guildId)
+ .update({
+ [`activeEvents.${id}`]: e.target.checked,
+ });
});
const handleAnnoucmentSelect = useCallback(
@@ -159,7 +139,6 @@ const Leveling = ({ location, guild: userConnectedGuildInfo }) => {
} catch (err) {
await guildLevelRef.set({ server: e.value });
}
- setDashboardOpen(true);
},
[guildId]
);
@@ -184,7 +163,6 @@ const Leveling = ({ location, guild: userConnectedGuildInfo }) => {
});
return newPlugs;
});
- setDashboardOpen(true);
}}
>
Disable
@@ -227,15 +205,10 @@ const Leveling = ({ location, guild: userConnectedGuildInfo }) => {
/>
{[...new Set(Object.values(allEvents || {}).map(val => val.category))].sort().map(category => (
-
+ <>
{category}
-
- Category Logging Channel Override{" "}
-
-
-
-
+
Channel Override
@@ -276,7 +249,6 @@ const Leveling = ({ location, guild: userConnectedGuildInfo }) => {
.sort()
.map(([key, event]) => (
{
/>
))}
-
+ >
))}
diff --git a/src/components/DashBoard/Discord/Plugins/PluginCard.js b/src/components/DashBoard/Discord/Plugins/PluginCard.js
index 8f2ee2a..5000f66 100644
--- a/src/components/DashBoard/Discord/Plugins/PluginCard.js
+++ b/src/components/DashBoard/Discord/Plugins/PluginCard.js
@@ -13,7 +13,7 @@ Modal.setAppElement("#root");
const PluginCard = ({ guild: guildId, ...props }) => {
const [modalOpen, setModalOpen] = useState(false);
- const { setActivePlugins, setDashboardOpen } = useContext(DiscordContext);
+ const { setActivePlugins } = useContext(DiscordContext);
const handleClick = useCallback(() => {
if (!props.active && !props.comingSoon) {
@@ -32,7 +32,6 @@ const PluginCard = ({ guild: guildId, ...props }) => {
});
return newPlugs;
});
- setDashboardOpen(true)
props.history.push(`${props.match.url}/${props.id}`);
};
diff --git a/src/components/DashBoard/Discord/Plugins/PluginCard.scss b/src/components/DashBoard/Discord/Plugins/PluginCard.scss
index 49783a0..452930e 100644
--- a/src/components/DashBoard/Discord/Plugins/PluginCard.scss
+++ b/src/components/DashBoard/Discord/Plugins/PluginCard.scss
@@ -172,9 +172,4 @@
margin: .5rem 0;
}
}
-}
-
-.MuiSvgIcon-root{
- font-size: inherit !important
- ;
}
\ No newline at end of file
diff --git a/src/components/DashBoard/Discord/Plugins/PluginHome.js b/src/components/DashBoard/Discord/Plugins/PluginHome.js
index 0c553e2..09db332 100644
--- a/src/components/DashBoard/Discord/Plugins/PluginHome.js
+++ b/src/components/DashBoard/Discord/Plugins/PluginHome.js
@@ -12,11 +12,10 @@ import { CommandContextProvider } from "../../../../contexts/CommandContext";
import { RoleContextProvider } from "../../../../contexts/RoleContext";
import App from "./App";
import Roles from "./Roles/Roles";
-import _ from "lodash";
const PluginHome = ({ match, guildId, connectedGuild }) => {
const [prefix, setPrefix] = useState("!");
- const { userDiscordInfo, activePlugins, setActivePlugins, saveOnType } = useContext(DiscordContext);
+ const { userDiscordInfo, activePlugins, setActivePlugins } = useContext(DiscordContext);
const [loading, setLoading] = useState(true);
useEffect(() => {
@@ -44,7 +43,6 @@ const PluginHome = ({ match, guildId, connectedGuild }) => {
})();
}, [connectedGuild]);
-
const prefixChange = useCallback(
async e => {
const value = e?.target?.value || "!";
@@ -65,7 +63,6 @@ const PluginHome = ({ match, guildId, connectedGuild }) => {
prefix: value,
});
}
- saveOnType();
},
[connectedGuild?.id]
);
diff --git a/src/components/DashBoard/Discord/Plugins/Roles/ManagerItem.js b/src/components/DashBoard/Discord/Plugins/Roles/ManagerItem.js
index 9f169da..85a27c5 100644
--- a/src/components/DashBoard/Discord/Plugins/Roles/ManagerItem.js
+++ b/src/components/DashBoard/Discord/Plugins/Roles/ManagerItem.js
@@ -43,7 +43,7 @@ const FancySwitch = withStyles({
opacity: "1 !important",
},
},
-
+ focusVisible: {},
})(Switch);
const ChannelParent = styled.span`
diff --git a/src/components/DashBoard/Discord/Plugins/Roles/Roles.js b/src/components/DashBoard/Discord/Plugins/Roles/Roles.js
index cc3722c..2f603cd 100644
--- a/src/components/DashBoard/Discord/Plugins/Roles/Roles.js
+++ b/src/components/DashBoard/Discord/Plugins/Roles/Roles.js
@@ -10,7 +10,7 @@ import CreateJoinManager from "./CreateJoinManager";
const Roles = ({ location, guild: userConnectedGuildInfo }) => {
const [MessageManagers, setMessageManagers] = useState([]);
const [JoinManager, setJoinManager] = useState();
- const { setActivePlugins, setDashboardOpen } = useContext(DiscordContext);
+ const { setActivePlugins } = useContext(DiscordContext);
const { state, create, setup } = useContext(RoleContext);
const guildId = userConnectedGuildInfo?.id;
@@ -67,7 +67,6 @@ const Roles = ({ location, guild: userConnectedGuildInfo }) => {
});
return newPlugs;
});
- setDashboardOpen(true)
}}
>
Disable
diff --git a/src/components/DashBoard/Settings/Setting.js b/src/components/DashBoard/Settings/Setting.js
index 84268ae..e42818a 100644
--- a/src/components/DashBoard/Settings/Setting.js
+++ b/src/components/DashBoard/Settings/Setting.js
@@ -41,7 +41,7 @@ const FancySwitch = withStyles({
opacity: "1 !important",
},
},
-
+ focusVisible: {},
})(Switch);
const Setting = props => {
diff --git a/src/contexts/DiscordContext.js b/src/contexts/DiscordContext.js
index bdfc930..02b5e4a 100644
--- a/src/contexts/DiscordContext.js
+++ b/src/contexts/DiscordContext.js
@@ -1,33 +1,25 @@
import React, { createContext } from "react";
import { useState } from "react";
-import _ from "lodash"
export const DiscordContext = createContext({});
export const DiscordContextProvider = props => {
const [userDiscordInfo, setUserDiscordInfo] = useState();
- const [userConnectedGuildInfo, setUserConnectedGuildInfo] = useState();
- const [userConnectedChannels, setUserConnectedChannels] = useState();
- const [activePlugins, setActivePlugins] = useState({});
- const [dashboardOpen, setDashboardOpen] = useState(false);
- const saveOnType = _.debounce(() => {
- setDashboardOpen(true);
- }, 100)
+ const [userConnectedGuildInfo, setUserConnectedGuildInfo] = useState();
+ const [userConnectedChannels, setUserConnectedChannels] = useState()
+ const [activePlugins, setActivePlugins] = useState({})
return (