Merge branch 'sentry-fixes' into 'develop'

Sentry fixes

See merge request soapbox-pub/soapbox-fe!1548
This commit is contained in:
Alex Gleason
2022-06-20 18:19:56 +00:00
5 changed files with 63 additions and 69 deletions

View File

@ -38,7 +38,7 @@ function showAlert(
}
const showAlertForError = (error: AxiosError<any>) => (dispatch: React.Dispatch<AnyAction>, _getState: any) => {
if (error.response) {
if (error?.response) {
const { data, status, statusText } = error.response;
if (status === 502) {
@ -52,7 +52,7 @@ const showAlertForError = (error: AxiosError<any>) => (dispatch: React.Dispatch<
let message: string | undefined = statusText;
if (data.error) {
if (data?.error) {
message = data.error;
}

View File

@ -229,9 +229,6 @@ export const logIn = (username: string, password: string) =>
throw error;
});
export const deleteSession = () =>
(dispatch: AppDispatch, getState: () => any) => api(getState).delete('/api/sign_out');
export const logOut = () =>
(dispatch: AppDispatch, getState: () => RootState) => {
const state = getState();
@ -246,10 +243,7 @@ export const logOut = () =>
token: state.auth.getIn(['users', account.url, 'access_token']),
};
return Promise.all([
dispatch(revokeOAuthToken(params)),
dispatch(deleteSession()),
]).finally(() => {
return dispatch(revokeOAuthToken(params)).finally(() => {
dispatch({ type: AUTH_LOGGED_OUT, account, standalone });
return dispatch(snackbar.success(messages.loggedOut));
});

View File

@ -11,10 +11,22 @@ export const useSystemTheme = (): SystemTheme => {
setDark(event.matches);
};
// Older versions of Safari on iOS don't support these events,
// so try-catch and do nothing.
useEffect(() => {
query.addEventListener('change', handleChange);
try {
query.addEventListener('change', handleChange);
} catch (e) {
// do nothing
}
return () => query.removeEventListener('change', handleChange);
return () => {
try {
query.removeEventListener('change', handleChange);
} catch (e) {
// do nothing
}
};
}, []);
return dark ? 'dark' : 'light';