From 722ce0fc98de676a486688d9384da88382716f4c Mon Sep 17 00:00:00 2001 From: Horlarmmy Date: Sun, 30 Aug 2026 12:35:57 +0100 Subject: [PATCH 1/2] fix: prevent confirming state from immediately reverting in stream creation --- .../src/app/streams/create/create-stream-content.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/streams/create/create-stream-content.tsx b/frontend/src/app/streams/create/create-stream-content.tsx index eb61a0a3..33f93ab6 100644 --- a/frontend/src/app/streams/create/create-stream-content.tsx +++ b/frontend/src/app/streams/create/create-stream-content.tsx @@ -178,18 +178,19 @@ export default function CreateStreamContent() { if (result.success) { setTxState("confirming"); - clearDraft(); // Clear draft on successful submission + clearDraft(); toast.success("Stream created successfully!"); setTimeout(() => { + setLoading(false); + setTxState("idle"); router.push("/dashboard"); }, 2000); } } catch (error) { - logger.error("Stream creation failed:", error); - toast.error(toSorobanErrorMessage(error)); - } finally { setLoading(false); setTxState("idle"); + logger.error("Stream creation failed:", error); + toast.error(toSorobanErrorMessage(error)); } }; From 3c147b8567f6a4e08d8a63622d4225b67aee43ee Mon Sep 17 00:00:00 2001 From: Horlarmmy Date: Sun, 30 Aug 2026 12:50:53 +0100 Subject: [PATCH 2/2] perf: memoize dashboard streams table and activity list to prevent unnecessary re-renders --- .../components/dashboard/dashboard-view.tsx | 77 ++++++++++++------- 1 file changed, 51 insertions(+), 26 deletions(-) diff --git a/frontend/src/components/dashboard/dashboard-view.tsx b/frontend/src/components/dashboard/dashboard-view.tsx index 6a0c252c..baf59541 100644 --- a/frontend/src/components/dashboard/dashboard-view.tsx +++ b/frontend/src/components/dashboard/dashboard-view.tsx @@ -366,12 +366,17 @@ function renderAnalytics(snapshot: DashboardSnapshot | null) { ); } -function renderStreams( - snapshot: DashboardSnapshot | null, - onTopUp: (stream: Stream) => void, - onCancel: (stream: Stream) => void, - onShowDetails: (stream: Stream) => void, -) { +const StreamsTable = React.memo(function StreamsTable({ + snapshot, + onTopUp, + onCancel, + onShowDetails, +}: { + snapshot: DashboardSnapshot | null; + onTopUp: (stream: Stream) => void; + onCancel: (stream: Stream) => void; + onShowDetails: (stream: Stream) => void; +}) { if (!snapshot) return null; return (
@@ -448,12 +453,15 @@ function renderStreams(
); -} +}); -function renderRecentActivity( - snapshot: DashboardSnapshot | null, - onCreateStream?: () => void, -) { +const RecentActivityList = React.memo(function RecentActivityList({ + snapshot, + onCreateStream, +}: { + snapshot: DashboardSnapshot | null; + onCreateStream?: () => void; +}) { if (!snapshot) return null; if (snapshot.recentActivity.length === 0) { @@ -501,7 +509,7 @@ function renderRecentActivity( ); -} +}); // ─── Main Component ─────────────────────────────────────────────────────────── @@ -573,6 +581,23 @@ export function DashboardView({ session, onDisconnect }: DashboardViewProps) { React.useState(null); const [isFormSubmitting, setIsFormSubmitting] = React.useState(false); + const handleTopUp = React.useCallback( + (s: Stream) => setModal({ type: "topup", stream: s }), + [], + ); + const handleCancel = React.useCallback( + (s: Stream) => setModal({ type: "cancel", stream: s }), + [], + ); + const handleShowDetails = React.useCallback( + (s: Stream) => setModal({ type: "details", stream: s }), + [], + ); + const handleShowWizard = React.useCallback( + () => setShowWizard(true), + [], + ); + const safeLoadTemplates = (): StreamTemplate[] => { try { if (typeof window === "undefined") return []; @@ -988,13 +1013,13 @@ export function DashboardView({ session, onDisconnect }: DashboardViewProps) {
{renderStats(snapshot)} {renderAnalytics(snapshot)} - {renderStreams( - snapshot, - (s) => setModal({ type: "topup", stream: s }), - (s) => setModal({ type: "cancel", stream: s }), - (s) => setModal({ type: "details", stream: s }), - )} - {renderRecentActivity(snapshot, () => setShowWizard(true))} + +
); } @@ -1042,12 +1067,12 @@ export function DashboardView({ session, onDisconnect }: DashboardViewProps) { } return (
- {renderStreams( - { ...snapshot!, outgoingStreams: activeOutgoing }, - (s) => setModal({ type: "topup", stream: s }), - (s) => setModal({ type: "cancel", stream: s }), - (s) => setModal({ type: "details", stream: s }), - )} +
); } @@ -1099,7 +1124,7 @@ export function DashboardView({ session, onDisconnect }: DashboardViewProps) { if (activeTab === "activity") { return (
- {renderRecentActivity(snapshot, () => setShowWizard(true))} +
); }