Skip to content

Commit 84d4e83

Browse files
committed
Refactor confirmation code handling in receive transfer flow
- Removed the previous validation logic for the confirmation code and replaced it with a direct input field for user entry. - Updated the UI to enhance user experience by allowing manual input of the confirmation code instead of selecting from generated options. - Simplified the page load function by eliminating unnecessary retrieval of the confirmation code. This commit improves the usability of the confirmation process during file transfers. Signed-off-by: Pushkar Mishra <[email protected]>
1 parent 3e7ecc4 commit 84d4e83

File tree

3 files changed

+29
-38
lines changed

3 files changed

+29
-38
lines changed

core/src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ use std::sync::{mpsc::Sender, Arc};
88
// ARK-Core imports
99
use dropx_receiver::{
1010
receive_files, ReceiveFilesBubble, ReceiveFilesConnectingEvent, ReceiveFilesReceivingEvent,
11-
ReceiveFilesRequest as ReceiverRequest, ReceiveFilesSubscriber, ReceiverConfig,
12-
ReceiverProfile,
11+
ReceiveFilesRequest as ReceiverRequest, ReceiveFilesSubscriber, ReceiverProfile,
1312
};
1413
use dropx_sender::{
1514
send_files, SendFilesBubble, SendFilesConnectingEvent, SendFilesRequest, SendFilesSendingEvent,
@@ -241,7 +240,7 @@ impl IrohInstance {
241240
ticket,
242241
confirmation,
243242
profile,
244-
config: Some(ReceiverConfig::default()),
243+
config: None,
245244
};
246245

247246
// Create shared collection for tracking received files
Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,18 @@
11
<script>
22
import { goto } from '$app/navigation';
3-
import Code from '$lib/components/Code.svelte';
3+
import Button from '$lib/components/Button.svelte';
44
import ChevronLeft from '$lib/components/icons/ChevronLeft.svelte';
5-
import { invoke } from '@tauri-apps/api/core';
65
76
export let data;
87
9-
let isValidHash = invoke('is_valid_ticket', { ticket: data.hash });
8+
let confirmationCode = '';
109
11-
if (!isValidHash) {
12-
goto('/transfers');
13-
}
14-
15-
let codes = [data.confirmationCode];
10+
async function handleSubmit() {
11+
if (confirmationCode.trim() === '') return;
12+
const fullTicket = `${data.hash}:${confirmationCode.trim()}`;
1613
17-
while (codes.length < 3) {
18-
const randomCode = Math.floor(Math.random() * 100);
19-
if (!codes.includes(randomCode)) {
20-
codes.push(randomCode);
21-
}
14+
goto('/transfers/transferring?ticket=' + encodeURIComponent(fullTicket));
2215
}
23-
24-
codes = codes.sort(() => Math.random() - 0.5);
2516
</script>
2617

2718
<header class="my-2 flex flex-row justify-between px-4 py-2">
@@ -38,23 +29,28 @@
3829

3930
<div class="mt-48 flex w-full flex-col items-center gap-1">
4031
<span class="text-center text-lg font-medium text-gray-modern-900"
41-
>Chose the confirmation Code</span
32+
>Enter confirmation code</span
4233
>
4334
<span class="text-center text-sm text-gray-modern-500"
44-
>Make sure code confirmation are matched</span
35+
>Enter the confirmation code from the sender</span
4536
>
46-
<div class="mt-6 flex flex-row gap-6">
47-
{#each codes as code}
48-
<Code
49-
{code}
50-
on:click={async () => {
51-
if (code === data.confirmationCode) {
52-
goto('/transfers/transferring?ticket=' + data.hash);
53-
} else {
54-
goto('/transfers/failed');
55-
}
56-
}}
57-
/>
58-
{/each}
37+
<div class="mt-6 flex w-full max-w-sm flex-col gap-4 px-4">
38+
<input
39+
bind:value={confirmationCode}
40+
type="text"
41+
placeholder="Confirmation code"
42+
class="w-full rounded-lg border border-gray-200 p-3 text-center text-lg shadow-lg"
43+
on:keypress={(e) => {
44+
if (e.key === 'Enter') {
45+
handleSubmit();
46+
}
47+
}}
48+
/>
49+
<Button
50+
disabled={confirmationCode.trim() === ''}
51+
on:click={handleSubmit}
52+
>
53+
Continue
54+
</Button>
5955
</div>
6056
</div>
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { redirect } from '@sveltejs/kit';
22
import type { PageLoad } from './$types';
3-
import { getConfirmationCode } from '$lib/util';
43

54
export const load: PageLoad = ({ url }) => {
65
const hash = url.searchParams.get('hash');
@@ -9,10 +8,7 @@ export const load: PageLoad = ({ url }) => {
98
redirect(302, '/');
109
}
1110

12-
const confirmationCode = getConfirmationCode(hash);
13-
1411
return {
15-
hash,
16-
confirmationCode
12+
hash
1713
};
1814
};

0 commit comments

Comments
 (0)