Skip to content

Commit

Permalink
[dashboard] fix #4068: load on Safari < 14
Browse files Browse the repository at this point in the history
  • Loading branch information
akosyakov committed Apr 26, 2021
1 parent 7f5fe36 commit babf0a4
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions components/dashboard/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,20 @@ function App() {
}
updateTheme();
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
mediaQuery.addEventListener('change', updateTheme);
if (mediaQuery instanceof EventTarget) {
mediaQuery.addEventListener('change', updateTheme);
} else {
// backward compatibility for Safari < 14
(mediaQuery as MediaQueryList).addListener(updateTheme);
}
window.addEventListener('storage', updateTheme);
return function cleanup() {
mediaQuery.removeEventListener('change', updateTheme);
if (mediaQuery instanceof EventTarget) {
mediaQuery.removeEventListener('change', updateTheme);
} else {
// backward compatibility for Safari < 14
(mediaQuery as MediaQueryList).removeListener(updateTheme);
}
window.removeEventListener('storage', updateTheme);
}
}, [localStorage.theme]);
Expand All @@ -79,7 +89,7 @@ function App() {
}
if (window.location.pathname.startsWith('/blocked')) {
return <div className="mt-48 text-center">
<img src={gitpodIcon} className="h-16 mx-auto"/>
<img src={gitpodIcon} className="h-16 mx-auto" />
<h1 className="mt-12 text-gray-500 text-3xl">Your account has been blocked.</h1>
<p className="mt-4 mb-8 text-lg w-96 mx-auto">Please contact support if you think this is an error. See also <a className="hover:text-blue-600 dark:hover:text-blue-400" href="https://www.gitpod.io/terms/">terms of service</a>.</p>
<a className="mx-auto" href="mailto:[email protected]?Subject=Blocked"><button className="secondary">Contact Support</button></a>
Expand Down Expand Up @@ -116,19 +126,19 @@ function App() {
<Route path="/admin/workspaces" component={WorkspacesSearch} />

<Route path={["/", "/login"]} exact>
<Redirect to="/workspaces"/>
<Redirect to="/workspaces" />
</Route>
<Route path={["/settings"]} exact>
<Redirect to="/account"/>
<Redirect to="/account" />
</Route>
<Route path={["/access-control"]} exact>
<Redirect to="/integrations"/>
<Redirect to="/integrations" />
</Route>
<Route path={["/subscription", "/usage", "/upgrade-subscription"]} exact>
<Redirect to="/plans"/>
<Redirect to="/plans" />
</Route>
<Route path={["/admin"]} exact>
<Redirect to="/admin/users"/>
<Redirect to="/admin/users" />
</Route>
<Route path="/sorry" exact>
<div className="mt-48 text-center">
Expand Down Expand Up @@ -171,7 +181,7 @@ function getURLHash() {
}

const renderMenu = (user?: User) => {
const left = [
const left = [
{
title: 'Workspaces',
link: '/workspaces',
Expand Down

0 comments on commit babf0a4

Please sign in to comment.