Skip to content

Commit

Permalink
#106 Always catch errs for group name
Browse files Browse the repository at this point in the history
  • Loading branch information
blms committed Dec 28, 2020
1 parent b7f12ef commit 6143e6b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ const AdminDocumentTable = ({ document, alerts, setAlerts }) => {
if (document) {
const fetchGroupState = async () => {
document.groups.map(async (group) => {
const name = await getGroupNameById(group);
const name = await getGroupNameById(group)
.catch((err) => {
setAlerts([...alerts, { text: err.message, variant: 'danger' }]);
});
setGroupState((prevState) => ({
...prevState,
[group]: name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ const DashboardDocumentList = ({
const fetchGroupState = async () => {
documents.map((document) => document.groups.map(async (group) => {
if (!documentGroupState[group]) {
const name = await getGroupNameById(group);
const name = await getGroupNameById(group)
.catch((err) => {
setAlerts([...alerts, { text: err.message, variant: 'danger' }]);
});
setDocumentGroupState((prevState) => ({
...prevState,
[group]: name,
Expand Down
5 changes: 4 additions & 1 deletion src/components/DocumentList/DocumentList.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ const DocumentList = ({
const fetchGroupState = async () => {
documents.map((document) => document.groups.map(async (group) => {
if (!groupState[group]) {
const name = await getGroupNameById(group);
const name = await getGroupNameById(group)
.catch((err) => {
setAlerts([...alerts, { text: err.message, variant: 'danger' }]);
});
setGroupState((prevState) => ({
...prevState,
[group]: name,
Expand Down

0 comments on commit 6143e6b

Please sign in to comment.