Skip to content

Commit f2f6fcc

Browse files
committed
fix(web): properly send file_complete message from the browser
1 parent 4d565cf commit f2f6fcc

File tree

5 files changed

+28
-5
lines changed

5 files changed

+28
-5
lines changed

site/bun.lockb

-26 Bytes
Binary file not shown.

site/components/layout.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,20 @@ export default function Layout({ children }: { children: ReactNode }) {
125125
type="text"
126126
value={pendingPeer}
127127
className="flex-grow p-3 border border-gray-600 rounded bg-gray-700 text-gray-200"
128-
onChange={(e) => setPendingPeer(e.target.value)}
128+
onChange={(e) => {
129+
// If pasting a URL, extract the fragment
130+
if (e.target.value.includes("#")) {
131+
try {
132+
const url = new URL(e.target.value);
133+
setPendingPeer(url.hash.slice(1));
134+
} catch {
135+
// If URL parsing fails, just use the value as-is
136+
setPendingPeer(e.target.value);
137+
}
138+
} else {
139+
setPendingPeer(e.target.value);
140+
}
141+
}}
129142
readOnly={Boolean(wasm.connectedPeer)}
130143
placeholder="Enter auth key"
131144
/>

site/next-env.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
/// <reference types="next/image-types/global" />
33

44
// NOTE: This file should not be edited
5-
// see https://nextjs.org/docs/pages/building-your-application/configuring/typescript for more information.
5+
// see https://nextjs.org/docs/pages/api-reference/config/typescript for more information.

site/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
"class-variance-authority": "^0.7.0",
2020
"clsx": "^2.1.1",
2121
"lucide-react": "^0.454.0",
22-
"next": "15.0.2",
22+
"next": "^15.1.0",
2323
"next-themes": "^0.4.3",
24-
"react": "19.0.0-rc.1",
25-
"react-dom": "19.0.0-rc.1",
24+
"react": "^19.0.0",
25+
"react-dom": "^19.0.0",
2626
"sonner": "^1.7.0",
2727
"tailwind-merge": "^2.5.4",
2828
"tailwind-scrollbar": "^3.1.0",

site/pages/send.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,16 @@ const FileTransfer: React.FC = () => {
243243
offset += chunk.byteLength;
244244

245245
if (offset >= file.size) {
246+
// Send file complete message before closing the channel
247+
const completeMessage: RtcMetadata = {
248+
type: "file_complete",
249+
fileMetadata: {
250+
fileName: file.name,
251+
fileSize: file.size,
252+
},
253+
};
254+
dc.send(JSON.stringify(completeMessage));
255+
246256
cleanupStatsInterval();
247257
const endTime = performance.now();
248258
const totalSeconds = (endTime - startTime) / 1000;

0 commit comments

Comments
 (0)