Skip to content

Commit babf0a4

Browse files
committed
[dashboard] fix #4068: load on Safari < 14
1 parent 7f5fe36 commit babf0a4

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

components/dashboard/src/App.tsx

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,20 @@ function App() {
6363
}
6464
updateTheme();
6565
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
66-
mediaQuery.addEventListener('change', updateTheme);
66+
if (mediaQuery instanceof EventTarget) {
67+
mediaQuery.addEventListener('change', updateTheme);
68+
} else {
69+
// backward compatibility for Safari < 14
70+
(mediaQuery as MediaQueryList).addListener(updateTheme);
71+
}
6772
window.addEventListener('storage', updateTheme);
6873
return function cleanup() {
69-
mediaQuery.removeEventListener('change', updateTheme);
74+
if (mediaQuery instanceof EventTarget) {
75+
mediaQuery.removeEventListener('change', updateTheme);
76+
} else {
77+
// backward compatibility for Safari < 14
78+
(mediaQuery as MediaQueryList).removeListener(updateTheme);
79+
}
7080
window.removeEventListener('storage', updateTheme);
7181
}
7282
}, [localStorage.theme]);
@@ -79,7 +89,7 @@ function App() {
7989
}
8090
if (window.location.pathname.startsWith('/blocked')) {
8191
return <div className="mt-48 text-center">
82-
<img src={gitpodIcon} className="h-16 mx-auto"/>
92+
<img src={gitpodIcon} className="h-16 mx-auto" />
8393
<h1 className="mt-12 text-gray-500 text-3xl">Your account has been blocked.</h1>
8494
<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>
8595
<a className="mx-auto" href="mailto:[email protected]?Subject=Blocked"><button className="secondary">Contact Support</button></a>
@@ -116,19 +126,19 @@ function App() {
116126
<Route path="/admin/workspaces" component={WorkspacesSearch} />
117127

118128
<Route path={["/", "/login"]} exact>
119-
<Redirect to="/workspaces"/>
129+
<Redirect to="/workspaces" />
120130
</Route>
121131
<Route path={["/settings"]} exact>
122-
<Redirect to="/account"/>
132+
<Redirect to="/account" />
123133
</Route>
124134
<Route path={["/access-control"]} exact>
125-
<Redirect to="/integrations"/>
135+
<Redirect to="/integrations" />
126136
</Route>
127137
<Route path={["/subscription", "/usage", "/upgrade-subscription"]} exact>
128-
<Redirect to="/plans"/>
138+
<Redirect to="/plans" />
129139
</Route>
130140
<Route path={["/admin"]} exact>
131-
<Redirect to="/admin/users"/>
141+
<Redirect to="/admin/users" />
132142
</Route>
133143
<Route path="/sorry" exact>
134144
<div className="mt-48 text-center">
@@ -171,7 +181,7 @@ function getURLHash() {
171181
}
172182

173183
const renderMenu = (user?: User) => {
174-
const left = [
184+
const left = [
175185
{
176186
title: 'Workspaces',
177187
link: '/workspaces',

0 commit comments

Comments
 (0)