Skip to content

Commit fc6e68c

Browse files
committed
Fix processGroupResult itemLabel
Signed-off-by: yubiuser <github@yubiuser.dev>
1 parent 9f978eb commit fc6e68c

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

scripts/js/groups-common.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,32 @@ function getGroups() {
5757

5858
// eslint-disable-next-line no-unused-vars
5959
function processGroupResult(data, type, done, notDone) {
60+
const itemLabel = entry => {
61+
if (typeof entry === "string") {
62+
return entry;
63+
}
64+
65+
if (entry && typeof entry === "object" && typeof entry.item === "string") {
66+
return entry.item;
67+
}
68+
69+
return String(entry);
70+
};
71+
6072
// Loop over data.processed.success and show toasts
6173
for (const item of data.processed.success) {
62-
utils.showAlert("success", "fas fa-pencil-alt", `Successfully ${done} ${type}`, item);
74+
utils.showAlert("success", "fas fa-pencil-alt", `Successfully ${done} ${type}`, itemLabel(item));
6375
}
6476

6577
// Loop over errors and display them
6678
for (const error of data.processed.errors) {
6779
console.log(error); // eslint-disable-line no-console
68-
utils.showAlert("error", "", `Error while ${notDone} ${type} ${error.item}`, error.error);
80+
utils.showAlert(
81+
"error",
82+
"",
83+
`Error while ${notDone} ${type} ${itemLabel(error)}`,
84+
typeof error.error === "string" ? error.error : String(error.error)
85+
);
6986
}
7087
}
7188

0 commit comments

Comments
 (0)