@bbearai/react 0.4.0 → 0.4.1

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/dist/index.js CHANGED
@@ -2487,6 +2487,7 @@ function ReportScreen({ nav, prefill }) {
2487
2487
  const [affectedRoute, setAffectedRoute] = (0, import_react8.useState)("");
2488
2488
  const [submitting, setSubmitting] = (0, import_react8.useState)(false);
2489
2489
  const [error, setError] = (0, import_react8.useState)(null);
2490
+ const submittingRef = (0, import_react8.useRef)(false);
2490
2491
  const observedRoute = (0, import_react8.useRef)(
2491
2492
  typeof window !== "undefined" ? window.location.pathname : "unknown"
2492
2493
  );
@@ -2494,6 +2495,8 @@ function ReportScreen({ nav, prefill }) {
2494
2495
  const isBugType = reportType === "bug" || reportType === "test_fail";
2495
2496
  const handleSubmit = async () => {
2496
2497
  if (!client || !description.trim() || images.isUploading) return;
2498
+ if (submittingRef.current) return;
2499
+ submittingRef.current = true;
2497
2500
  setSubmitting(true);
2498
2501
  setError(null);
2499
2502
  try {
@@ -2515,17 +2518,18 @@ function ReportScreen({ nav, prefill }) {
2515
2518
  if (!result.success) {
2516
2519
  setError(result.error || "Failed to submit report. Please try again.");
2517
2520
  setSubmitting(false);
2521
+ submittingRef.current = false;
2518
2522
  return;
2519
2523
  }
2520
2524
  if (prefill?.assignmentId) {
2521
2525
  await refreshAssignments();
2522
2526
  }
2523
- setSubmitting(false);
2524
2527
  nav.replace({ name: "REPORT_SUCCESS" });
2525
2528
  } catch (err) {
2526
2529
  console.error("BugBear: Report submission error", err);
2527
2530
  setError(err instanceof Error ? err.message : "An unexpected error occurred. Please try again.");
2528
2531
  setSubmitting(false);
2532
+ submittingRef.current = false;
2529
2533
  }
2530
2534
  };
2531
2535
  const typeOptions = [
@@ -3280,7 +3284,7 @@ function ThreadDetailScreen({
3280
3284
  children: msg.content
3281
3285
  }
3282
3286
  ),
3283
- msg.attachments && msg.attachments.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { style: { marginTop: 8, display: "flex", flexDirection: "column", gap: 6 }, children: msg.attachments.filter((a) => a.type === "image").map((att, idx) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
3287
+ msg.attachments && msg.attachments.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { style: { marginTop: 8, display: "flex", flexDirection: "column", gap: 6 }, children: msg.attachments.filter((a) => a.type === "image" && typeof a.url === "string" && /^https?:\/\//i.test(a.url)).map((att, idx) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
3284
3288
  "img",
3285
3289
  {
3286
3290
  src: att.url,
package/dist/index.mjs CHANGED
@@ -2458,6 +2458,7 @@ function ReportScreen({ nav, prefill }) {
2458
2458
  const [affectedRoute, setAffectedRoute] = useState6("");
2459
2459
  const [submitting, setSubmitting] = useState6(false);
2460
2460
  const [error, setError] = useState6(null);
2461
+ const submittingRef = useRef2(false);
2461
2462
  const observedRoute = useRef2(
2462
2463
  typeof window !== "undefined" ? window.location.pathname : "unknown"
2463
2464
  );
@@ -2465,6 +2466,8 @@ function ReportScreen({ nav, prefill }) {
2465
2466
  const isBugType = reportType === "bug" || reportType === "test_fail";
2466
2467
  const handleSubmit = async () => {
2467
2468
  if (!client || !description.trim() || images.isUploading) return;
2469
+ if (submittingRef.current) return;
2470
+ submittingRef.current = true;
2468
2471
  setSubmitting(true);
2469
2472
  setError(null);
2470
2473
  try {
@@ -2486,17 +2489,18 @@ function ReportScreen({ nav, prefill }) {
2486
2489
  if (!result.success) {
2487
2490
  setError(result.error || "Failed to submit report. Please try again.");
2488
2491
  setSubmitting(false);
2492
+ submittingRef.current = false;
2489
2493
  return;
2490
2494
  }
2491
2495
  if (prefill?.assignmentId) {
2492
2496
  await refreshAssignments();
2493
2497
  }
2494
- setSubmitting(false);
2495
2498
  nav.replace({ name: "REPORT_SUCCESS" });
2496
2499
  } catch (err) {
2497
2500
  console.error("BugBear: Report submission error", err);
2498
2501
  setError(err instanceof Error ? err.message : "An unexpected error occurred. Please try again.");
2499
2502
  setSubmitting(false);
2503
+ submittingRef.current = false;
2500
2504
  }
2501
2505
  };
2502
2506
  const typeOptions = [
@@ -3251,7 +3255,7 @@ function ThreadDetailScreen({
3251
3255
  children: msg.content
3252
3256
  }
3253
3257
  ),
3254
- msg.attachments && msg.attachments.length > 0 && /* @__PURE__ */ jsx11("div", { style: { marginTop: 8, display: "flex", flexDirection: "column", gap: 6 }, children: msg.attachments.filter((a) => a.type === "image").map((att, idx) => /* @__PURE__ */ jsx11(
3258
+ msg.attachments && msg.attachments.length > 0 && /* @__PURE__ */ jsx11("div", { style: { marginTop: 8, display: "flex", flexDirection: "column", gap: 6 }, children: msg.attachments.filter((a) => a.type === "image" && typeof a.url === "string" && /^https?:\/\//i.test(a.url)).map((att, idx) => /* @__PURE__ */ jsx11(
3255
3259
  "img",
3256
3260
  {
3257
3261
  src: att.url,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbearai/react",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "BugBear React components for web apps",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",