Merge branch 'sentry-fixes' into 'develop'
Sentry fixes See merge request soapbox-pub/soapbox-fe!1548
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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));
|
||||
});
|
||||
|
||||
@ -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';
|
||||
|
||||
Reference in New Issue
Block a user