Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/dashboard/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { getStreamAddress, getStreamInfo, getWithdrawable, type StreamInfo } fro
import { fromStroops } from "@/lib/format";
import { refreshStreamData } from "@/lib/queryClient";
import { useNetworkStatus } from "@/hooks/useNetworkStatus";
import { isFulfilled } from "@/lib/safe-operations";

type Tab = "receiving" | "sending";
type StreamStatus = "active" | "paused" | "ended" | "cancelled";
Expand Down Expand Up @@ -67,7 +68,7 @@ async function loadRows(
for (let i = 0; i < uniqueIds.length; i++) {
const r = addrResults[i];
if (signal.aborted) return { rows: [], failedCount: 0 };
if (r && r.status === "fulfilled" && r.value && typeof r.value === "string") {
if (isFulfilled(r) && r.value && typeof r.value === "string") {
addrPairs.push({ id: uniqueIds[i]!, rowId: uniqueIds[i]!.toString(), addr: r.value });
} else {
failedCount++;
Expand All @@ -93,8 +94,7 @@ async function loadRows(
const r = results[j];
const pair = batch[j]!;
if (
r &&
r.status === "fulfilled" &&
isFulfilled(r) &&
r.value[0] &&
typeof r.value[0] === "object" &&
typeof r.value[0].ratePerSecond === "bigint"
Expand Down
14 changes: 14 additions & 0 deletions lib/safe-operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,3 +329,17 @@ export function clearIdempotencyKeys(): void {
activeIdempotencyKeys.clear();
}


// ── Promise.allSettled Helpers ───────────────────────────────────────────────

/**
* Type guard for a fulfilled Promise.allSettled result.
*
* Use this instead of inline `r && r.status === 'fulfilled'` so
* TypeScript narrows the value correctly under `noUncheckedIndexedAccess`.
*/
export function isFulfilled<T>(
result: PromiseSettledResult<T> | undefined,
): result is PromiseFulfilledResult<T> {
return result !== undefined && result.status === 'fulfilled';
}
Loading