Skip to content

Commit 5bf613d

Browse files
authored
Merge pull request #943 from Godbrand0/fix-issues-811-813-816
Fix issues #811, #813, #816
2 parents 8b2c0fe + 21017e4 commit 5bf613d

5 files changed

Lines changed: 9 additions & 18 deletions

File tree

backend/src/controllers/stream.controller.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,7 @@ export const listStreams = async (req: Request, res: Response) => {
286286
: DEFAULT_STREAM_PAGE_SIZE,
287287
MAX_STREAM_PAGE_SIZE,
288288
);
289-
const parsedOffset =
290-
typeof offset === "string" ? Number.parseInt(offset, 10) || 0 : 0;
289+
const parsedOffset = typeof offset === 'string' ? Math.max(0, Number.parseInt(offset, 10) || 0) : 0;
291290

292291
// Validate sort field
293292
const validSortFields = [
@@ -425,9 +424,9 @@ export const getStreamEvents = async (req: Request, res: Response) => {
425424
);
426425

427426
let offset = 0;
428-
if (rawOffset && typeof rawOffset === "string") {
429-
offset = Number.parseInt(rawOffset, 10) || 0;
430-
} else if (rawPage && typeof rawPage === "string" && !cursor) {
427+
if (rawOffset && typeof rawOffset === 'string') {
428+
offset = Math.max(0, Number.parseInt(rawOffset, 10) || 0);
429+
} else if (rawPage && typeof rawPage === 'string' && !cursor) {
431430
const page = Number.parseInt(rawPage, 10) || 1;
432431
offset = Math.max(0, (page - 1) * limit);
433432
}
@@ -749,9 +748,7 @@ export const topUpStreamHandler = async (req: Request, res: Response) => {
749748
.json({ streamId, txHash, depositedAmount: newDeposited });
750749
} catch (error: any) {
751750
logger.error(`[topUp] stream=${streamId} error:`, error);
752-
return res
753-
.status(500)
754-
.json({ error: error.message ?? "Internal server error" });
751+
return res.status(400).json({ error: 'Failed to top up stream on chain', message: error.message ?? 'Unknown error' });
755752
}
756753
};
757754

backend/src/controllers/user.controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export const getUserEvents = async (req: Request, res: Response, next: NextFunct
8585
rawLimit && typeof rawLimit === 'string' ? (Number.parseInt(rawLimit, 10) || DEFAULT_EVENTS_PAGE_SIZE) : DEFAULT_EVENTS_PAGE_SIZE,
8686
MAX_EVENTS_PAGE_SIZE
8787
);
88-
const offset = rawOffset && typeof rawOffset === 'string' ? (Number.parseInt(rawOffset, 10) || 0) : 0;
88+
const offset = rawOffset && typeof rawOffset === 'string' ? Math.max(0, Number.parseInt(rawOffset, 10) || 0) : 0;
8989

9090
const whereClause = {
9191
stream: {
Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
11
import { Router } from 'express';
2-
import { requireAuth } from '../../../middleware/auth.js';
3-
import { withdrawHandler } from './withdraw.js';
42
import oldStreamRoutes from '../stream.routes.js';
5-
63
const router = Router();
74

85
// Mount the old routes first
96
router.use('/', oldStreamRoutes);
107

11-
/**
12-
* Override/Add POST /api/v1/streams/:streamId/withdraw
13-
*/
14-
router.post('/:streamId/withdraw', requireAuth, withdrawHandler as any);
15-
168
export default router;

frontend/src/components/dashboard/dashboard-view.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ const SIDEBAR_ITEMS: SidebarItem[] = [
107107
/** Shimmer card used as a placeholder while data loads */
108108
function SkeletonCard({ className = "" }: { className?: string }) {
109109
return (
110+
<div className={`relative overflow-hidden rounded-2xl ${className}`}>
111+
<Skeleton className="absolute inset-0" aria-hidden="true" />
110112
<div
111113
className={`relative overflow-hidden rounded-2xl ${className}`}
112114
aria-hidden="true"

frontend/src/hooks/useIncomingStreams.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export function useWithdrawIncomingStream(
9595

9696
return { previousStreams, expectedWithdrawn };
9797
},
98-
onSuccess: async (result, stream, _variables, context) => {
98+
onSuccess: async (result, stream, context) => {
9999
if (publicKey) {
100100
const ctx = context as {
101101
previousStreams?: IncomingStreamRecord[];

0 commit comments

Comments
 (0)