@growth-operations/ui-shared 1.6.8 → 1.6.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@growth-operations/ui-shared",
3
- "version": "1.6.8",
3
+ "version": "1.6.9",
4
4
  "description": "Shared HubSpot UI-extension modules (Home, Billing) for Growth Operations apps.",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -64,6 +64,7 @@ function DefaultAlertRow({
64
64
  context,
65
65
  alert,
66
66
  refresh,
67
+ onDismissed,
67
68
  fetchOptions,
68
69
  renderRowActions,
69
70
  }) {
@@ -73,7 +74,9 @@ function DefaultAlertRow({
73
74
  setDismissing(true);
74
75
  try {
75
76
  await dismissAlert(context, alert.id, fetchOptions);
76
- await refresh();
77
+ // Optimistically drop just this row from local state — no full re-fetch
78
+ // of the whole alert list on every dismiss.
79
+ onDismissed(alert.id);
77
80
  } finally {
78
81
  setDismissing(false);
79
82
  }
@@ -161,6 +164,14 @@ export function AlertsTab({
161
164
  }
162
165
  };
163
166
 
167
+ // Optimistically remove a dismissed alert from local state instead of
168
+ // re-fetching the whole list. Keeps the dismiss interaction to a single API
169
+ // call (the dismiss itself).
170
+ const removeAlertLocally = (id) => {
171
+ setAlerts((prev) => prev.filter((a) => a.id !== id));
172
+ setTotal((t) => Math.max(0, t - 1));
173
+ };
174
+
164
175
  useEffect(() => {
165
176
  load(1, level);
166
177
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -212,8 +223,12 @@ export function AlertsTab({
212
223
  const refresh = () => load(page, level);
213
224
  // Full-row override escape hatch: the app owns the cells.
214
225
  if (renderRow) {
226
+ // Optimistic dismiss (drop the row locally); refresh stays
227
+ // available for apps that want a full reload.
215
228
  const dismiss = () =>
216
- dismissAlert(context, alert.id, fetchOptions).then(refresh);
229
+ dismissAlert(context, alert.id, fetchOptions).then(() =>
230
+ removeAlertLocally(alert.id)
231
+ );
217
232
  return (
218
233
  <React.Fragment key={alert.id}>
219
234
  {renderRow(alert, {
@@ -232,6 +247,7 @@ export function AlertsTab({
232
247
  alert={alert}
233
248
  fetchOptions={fetchOptions}
234
249
  refresh={refresh}
250
+ onDismissed={removeAlertLocally}
235
251
  renderRowActions={renderRowActions}
236
252
  />
237
253
  );