diff --git a/src/App.jsx b/src/App.jsx index 157918e1..61b260b2 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -3,6 +3,7 @@ import { ToastContainer } from 'react-toastify'; import Background from 'features/background/Background'; import Widgets from 'features/misc/views/Widgets'; import Modals from 'features/misc/modals/Modals'; +import CustomWidgets from 'features/misc/CustomWidgets'; import { loadSettings, moveSettings } from 'utils/settings'; import EventBus from 'utils/eventbus'; import variables from 'config/variables'; @@ -60,6 +61,7 @@ const App = () => { return ( {showBackground && } + { + const [widgets, setWidgets] = useState([]); + + useEffect(() => { + const loadWidgets = () => { + const stored = JSON.parse(localStorage.getItem('customWidgets') || '[]'); + setWidgets(stored); + }; + + loadWidgets(); + + const handleRefresh = () => { + loadWidgets(); + }; + + EventBus.on('refresh-widgets', handleRefresh); + window.addEventListener('storage', handleRefresh); + + return () => { + EventBus.off('refresh-widgets', handleRefresh); + window.removeEventListener('storage', handleRefresh); + }; + }, []); + + // Only render center-positioned widgets + const centerWidgets = widgets.filter((w) => w.position === 'center'); + + if (centerWidgets.length === 0) { + return null; + } + + return ( + <> + {centerWidgets.map((widget) => ( +
+