Compare commits

...

2 Commits

Author SHA1 Message Date
Ceda EI 90a03dc17c Make no-unused-vars a warning instead of an error 2021-01-01 12:54:19 +05:30
Ceda EI e1c42c90d5 Fix rendering issues with plugins
Plugins wouldn't render if the number of hooks changed. This was because
the dynamic content substitution would create variable number of hooks.
This has been fixed by creating an element instead of placing content.
2021-01-01 01:23:42 +05:30
3 changed files with 6 additions and 5 deletions

View File

@ -34,7 +34,8 @@ module.exports = {
"semi": [
"error",
"always"
]
],
"no-unused-vars": [1]
},
"settings": {
"react": {

View File

@ -3,19 +3,19 @@ import { useSelector, useDispatch } from "react-redux";
import { Box, Button, Clock } from "grommet";
import { setPlugin, selectCore } from "./coreSlice";
import * as plugins from "./plugins";
import plugins from "./plugins";
function Core() {
const coreState = useSelector(selectCore);
const dispatch = useDispatch();
const plugin = plugins.default[coreState.plugin];
const plugin = plugins[coreState.plugin];
const props = {
data: coreState.data,
close: () => dispatch(setPlugin(false))
};
const dummyButtons = ["Maps", "Home Devices", "Phone"];
return <>
{plugin ? plugin(props) : (
{plugin ? React.createElement(plugin, props, null) : (
<Box
align="center"
background="light-1"

View File

@ -17,8 +17,8 @@ function WebSocketProvider({ children }) {
socket = io.connect(WS_BASE);
socket.on("switchPlugin", (payload) => {
dispatch(setData(payload.data || {}));
dispatch(setPlugin(payload.plugin));
dispatch(setData(payload.data));
if (payload.time) {
setTimeout(() => {
dispatch(setData({}));