@remit/ui 0.0.95 → 0.0.96
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
|
@@ -245,9 +245,11 @@ export const SpamActionUnavailable: Story = {
|
|
|
245
245
|
* action (a report against a message already in Junk is a real no-op-move,
|
|
246
246
|
* issue #648), so without a pending label the button gives no visible
|
|
247
247
|
* response at all until the request lands — the dead-button failure the
|
|
248
|
-
* coding standards call the worst outcome. The button
|
|
249
|
-
*
|
|
250
|
-
*
|
|
248
|
+
* coding standards call the worst outcome. The button is disabled for the
|
|
249
|
+
* duration: the server dedupes message ids only within a single request, so
|
|
250
|
+
* a second press mid-flight would fire a second, concurrent request rather
|
|
251
|
+
* than join the first (issue #648 review). Still visibly a button, never
|
|
252
|
+
* dead — the "Reporting…" label carries that.
|
|
251
253
|
*/
|
|
252
254
|
export const ReportSpamPending: Story = {
|
|
253
255
|
args: {
|
|
@@ -188,10 +188,12 @@ export interface IntelligencePanelProps {
|
|
|
188
188
|
* update for this action (issue #648: the client can't predict whether a
|
|
189
189
|
* report against a message already in Junk is a no-op), so without this
|
|
190
190
|
* the button gives no visible response at all until the request lands — a
|
|
191
|
-
* dead button is the worst outcome. Swaps the label to "Reporting…"
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
191
|
+
* dead button is the worst outcome. Swaps the label to "Reporting…" AND
|
|
192
|
+
* disables the button: the server dedupes message ids only within a
|
|
193
|
+
* single request, so a second press mid-flight fires a second, concurrent
|
|
194
|
+
* request rather than joining the first (issue #648 review — for "Not
|
|
195
|
+
* spam" this races the restore move and can surface a spurious
|
|
196
|
+
* "try again in a moment" for an undo that already succeeded).
|
|
195
197
|
*/
|
|
196
198
|
reportSpamPending?: boolean;
|
|
197
199
|
/** True while a "Not spam" (undo) press is in flight. Same treatment as `reportSpamPending`. */
|
|
@@ -336,17 +338,21 @@ function QuickAction({
|
|
|
336
338
|
active,
|
|
337
339
|
danger,
|
|
338
340
|
onClick,
|
|
341
|
+
pending,
|
|
339
342
|
}: {
|
|
340
343
|
icon: ReactNode;
|
|
341
344
|
label: string;
|
|
342
345
|
active?: boolean;
|
|
343
346
|
danger?: boolean;
|
|
344
347
|
onClick?: () => void;
|
|
348
|
+
/** Disable the button without hiding it — a request for this action is already in flight. */
|
|
349
|
+
pending?: boolean;
|
|
345
350
|
}) {
|
|
346
351
|
// No handler means the action cannot be serviced yet (the sender's address
|
|
347
352
|
// record has not resolved). Render it visibly unavailable rather than as a
|
|
348
|
-
// live button that swallows the click.
|
|
349
|
-
|
|
353
|
+
// live button that swallows the click. `pending` disables it for the same
|
|
354
|
+
// reason once a press is in flight.
|
|
355
|
+
const disabled = onClick === undefined || pending === true;
|
|
350
356
|
return (
|
|
351
357
|
<button
|
|
352
358
|
type="button"
|
|
@@ -465,6 +471,7 @@ export function IntelligencePanel({
|
|
|
465
471
|
label={notSpamPending ? "Undoing…" : "Not spam"}
|
|
466
472
|
active
|
|
467
473
|
onClick={actions.onNotSpam}
|
|
474
|
+
pending={notSpamPending}
|
|
468
475
|
/>
|
|
469
476
|
)}
|
|
470
477
|
{actions?.onReportSpam && (
|
|
@@ -473,6 +480,7 @@ export function IntelligencePanel({
|
|
|
473
480
|
label={reportSpamPending ? "Reporting…" : "Report spam"}
|
|
474
481
|
danger
|
|
475
482
|
onClick={actions.onReportSpam}
|
|
483
|
+
pending={reportSpamPending}
|
|
476
484
|
/>
|
|
477
485
|
)}
|
|
478
486
|
<QuickAction
|