Skip to content

Commit

Permalink
fix: handle alert returned async by parentAlertsAdd [LIBS-695] (#1388)
Browse files Browse the repository at this point in the history
* fix: handle async parentAlertsAdd

* chore: fix comment
  • Loading branch information
KaiVandivier authored Oct 9, 2024
1 parent 1713f0f commit 9c989b2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions services/alerts/src/useAlert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,18 @@ export const useAlert = (
typeof options === 'function' ? options(props) : options

if (plugin && parentAlertsAdd && !showAlertsInPlugin) {
alertRef.current = parentAlertsAdd(
// Functions passed through post-robot are asynchronous
parentAlertsAdd(
{
message: resolvedMessage,
options: resolvedOptions,
},
alertRef
)
// Conditional chaining gives backwards compatibility
// with cli-app-scripts < 12
)?.then((newAlert: Alert) => {
alertRef.current = newAlert
})
} else {
alertRef.current = add(
{
Expand Down

0 comments on commit 9c989b2

Please sign in to comment.