diff --git a/webapp/README.md b/webapp/README.md index 0eff612..cfc3379 100644 --- a/webapp/README.md +++ b/webapp/README.md @@ -7,7 +7,7 @@ The EteSync Web App - Use EteSync from the browser! ![GitHub tag](https://img.shields.io/github/tag/etesync/etesync-web.svg) -[![Chat on freenode](https://img.shields.io/badge/irc.freenode.net-%23EteSync-blue.svg)](https://webchat.freenode.net/?channels=#etesync) +[![Chat with us](https://img.shields.io/badge/chat-IRC%20|%20Matrix%20|%20Web-blue.svg)](https://www.etebase.com/community-chat/) For notes, please refer to [the EteSync Notes](https://github.com/etesync/etesync-notes/) repository. diff --git a/webapp/src/App.tsx b/webapp/src/App.tsx index 6d63893..e3b2aa3 100644 --- a/webapp/src/App.tsx +++ b/webapp/src/App.tsx @@ -146,10 +146,35 @@ export default function App() { const [errorsDialog, setErrorsDialog] = React.useState(false); const dispatch = useDispatch(); const etebase = useCredentials(); - const darkMode = useSelector((state: store.StoreState) => state.settings.darkMode); + const darkModeUserSelection = useSelector((state: store.StoreState) => state.settings.darkModeUserSelection); const fetchCount = useSelector((state: store.StoreState) => state.fetchCount); const errors = useSelector((state: store.StoreState) => state.errors); + function shouldBeDark(userSelection: string, browserPreference: boolean): boolean { + if (userSelection === "auto") { + return browserPreference; + } else if (userSelection === "dark") { + return true; + } + return false; + } + + const [darkModeBrowserPreference, setDarkModeBrowserPreference] = React.useState(Boolean(window.matchMedia?.("(prefers-color-scheme: dark)").matches)); + const handleBrowserDarkModePreferenceChange = React.useCallback((e) => { + setDarkModeBrowserPreference(e.matches); + }, []); + React.useEffect(() => { + window.matchMedia?.("(prefers-color-scheme: dark)").addEventListener("change", handleBrowserDarkModePreferenceChange); + return () => { + window.matchMedia?.("(prefers-color-scheme: dark)").removeEventListener("change", handleBrowserDarkModePreferenceChange); + }; + }, [handleBrowserDarkModePreferenceChange]); + + const [darkMode, setDarkMode] = React.useState(() => shouldBeDark(darkModeUserSelection, darkModeBrowserPreference)); + React.useEffect(() => { + setDarkMode(shouldBeDark(darkModeUserSelection, darkModeBrowserPreference)); + }, [darkModeUserSelection, darkModeBrowserPreference]); + async function refresh() { const syncManager = SyncManager.getManager(etebase!); const sync = syncManager.sync(); diff --git a/webapp/src/Calendars/Event.tsx b/webapp/src/Calendars/Event.tsx index bddd33e..a1fe1d4 100644 --- a/webapp/src/Calendars/Event.tsx +++ b/webapp/src/Calendars/Event.tsx @@ -35,7 +35,7 @@ class Event extends React.PureComponent {
{this.props.item.description}
+{this.props.item.description}
{(this.props.item.attendees.length > 0) && (