Skip to content

Commit

Permalink
Merge pull request #437 from KKoukiou/rhbz#2308279
Browse files Browse the repository at this point in the history
Reimplement error handling using error boundaries
  • Loading branch information
KKoukiou authored Sep 16, 2024
2 parents 8429c2c + 3c81a36 commit 9fa0ba7
Show file tree
Hide file tree
Showing 12 changed files with 263 additions and 328 deletions.
62 changes: 22 additions & 40 deletions src/actions/localization-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,66 +24,48 @@ import {
getLocales,
} from "../apis/localization.js";

import { setCriticalErrorAction } from "./miscellaneous-actions.js";

export const getLanguagesAction = () => {
return async (dispatch) => {
try {
const languageIds = await getLanguages();
const languageIds = await getLanguages();

return Promise.all([
dispatch(getCommonLocalesAction()),
...languageIds.map(language => dispatch(getLanguageDataAction({ language })))
]);
} catch (error) {
dispatch(setCriticalErrorAction(error));
}
return Promise.all([
dispatch(getCommonLocalesAction()),
...languageIds.map(language => dispatch(getLanguageDataAction({ language })))
]);
};
};

export const getLanguageDataAction = ({ language }) => {
return async (dispatch) => {
try {
const localeIds = await getLocales({ lang: language });
const languageData = await getLanguageData({ lang: language });
const locales = await Promise.all(localeIds.map(async locale => await getLocaleData({ locale })));
const localeIds = await getLocales({ lang: language });
const languageData = await getLanguageData({ lang: language });
const locales = await Promise.all(localeIds.map(async locale => await getLocaleData({ locale })));

return dispatch({
payload: { languageData: { [language]: { languageData, locales } } },
type: "GET_LANGUAGE_DATA"
});
} catch (error) {
dispatch(setCriticalErrorAction(error));
}
return dispatch({
payload: { languageData: { [language]: { languageData, locales } } },
type: "GET_LANGUAGE_DATA"
});
};
};

export const getLanguageAction = () => {
return async (dispatch) => {
try {
const language = await getLanguage();
const language = await getLanguage();

return dispatch({
payload: { language },
type: "GET_LANGUAGE"
});
} catch (error) {
dispatch(setCriticalErrorAction(error));
}
return dispatch({
payload: { language },
type: "GET_LANGUAGE"
});
};
};

export const getCommonLocalesAction = () => {
return async (dispatch) => {
try {
const commonLocales = await getCommonLocales();
const commonLocales = await getCommonLocales();

return dispatch({
payload: { commonLocales },
type: "GET_COMMON_LOCALES"
});
} catch (error) {
dispatch(setCriticalErrorAction(error));
}
return dispatch({
payload: { commonLocales },
type: "GET_COMMON_LOCALES"
});
};
};
26 changes: 0 additions & 26 deletions src/actions/miscellaneous-actions.js

This file was deleted.

30 changes: 10 additions & 20 deletions src/actions/network-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,24 @@ import {
getConnected, getHostname,
} from "../apis/network.js";

import { setCriticalErrorAction } from "./miscellaneous-actions.js";

export const getConnectedAction = () => {
return async (dispatch) => {
try {
const connected = await getConnected();
const connected = await getConnected();

return dispatch({
payload: { connected },
type: "GET_NETWORK_CONNECTED"
});
} catch (error) {
setCriticalErrorAction(error);
}
return dispatch({
payload: { connected },
type: "GET_NETWORK_CONNECTED"
});
};
};

export const getHostnameAction = () => {
return async (dispatch) => {
try {
const hostname = await getHostname();
const hostname = await getHostname();

return dispatch({
payload: { hostname },
type: "GET_NETWORK_HOSTNAME"
});
} catch (error) {
setCriticalErrorAction(error);
}
return dispatch({
payload: { hostname },
type: "GET_NETWORK_HOSTNAME"
});
};
};
16 changes: 5 additions & 11 deletions src/actions/runtime-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,13 @@ import {
getPasswordPolicies,
} from "../apis/runtime.js";

import { setCriticalErrorAction } from "./miscellaneous-actions.js";

export const getPasswordPoliciesAction = () => {
return async (dispatch) => {
try {
const passwordPolicies = await getPasswordPolicies();
const passwordPolicies = await getPasswordPolicies();

return dispatch({
payload: { passwordPolicies },
type: "GET_RUNTIME_PASSWORD_POLICIES"
});
} catch (error) {
setCriticalErrorAction(error);
}
return dispatch({
payload: { passwordPolicies },
type: "GET_RUNTIME_PASSWORD_POLICIES"
});
};
};
Loading

0 comments on commit 9fa0ba7

Please sign in to comment.