Skip to content

Commit 678e307

Browse files
Merge pull request #119 from tonyantony300/feature/clear-selection
add ability to clear selection
2 parents d64dd62 + 6725cbd commit 678e307

14 files changed

Lines changed: 60 additions & 38 deletions

File tree

sendme/src/core/receive.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,12 @@ pub async fn download(
164164
0.0
165165
};
166166

167-
emit_progress_event(&app_handle, offset.min(payload_size), payload_size, speed_bps);
167+
emit_progress_event(
168+
&app_handle,
169+
offset.min(payload_size),
170+
payload_size,
171+
speed_bps,
172+
);
168173
}
169174
}
170175
GetProgressItem::Done(value) => {

sendme/src/core/send.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,9 @@ mod tests {
366366
}
367367
let path = entry.into_path();
368368
let relative = path.strip_prefix(root).ok()?;
369-
canonicalized_path_to_string(relative, true).ok().map(|name| (name, path))
369+
canonicalized_path_to_string(relative, true)
370+
.ok()
371+
.map(|name| (name, path))
370372
})
371373
.collect();
372374

web-app/src/components/LanguageSwitcher.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const LANGUAGES = [
2929
{ value: 'uk', label: 'Українська' },
3030
{ value: 'zh-CN', label: '简体中文' },
3131
{ value: 'zh-TW', label: '繁體中文' },
32-
]
32+
]
3333

3434
export function LanguageSwitcher(props: ButtonProps) {
3535
const { i18n } = useAppTranslation()

web-app/src/components/common/TransferSuccessScreen.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,12 @@ export function TransferSuccessScreen({
7373
{wasStopped ? (
7474
<XCircle size={44} className="text-destructive" />
7575
) : (
76-
<CheckCircle
77-
size={44}
78-
className="text-success"
79-
/>
76+
<CheckCircle size={44} className="text-success" />
8077
)}
8178
</div>
8279

8380
<div className="text-center">
84-
<h2
85-
className="text-2xl font-semibold mb-2"
86-
>
81+
<h2 className="text-2xl font-semibold mb-2">
8782
{wasStopped
8883
? t('common:transfer.stopped')
8984
: t('common:transfer.complete')}

web-app/src/components/receiver/InstructionsCard.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@ import type { InstructionsCardProps } from '../../types/ui'
33
export function InstructionsCard(_props: InstructionsCardProps) {
44
return (
55
<div className="p-4 rounded-lg border">
6-
<h3
7-
className="text-sm font-medium mb-2"
8-
>
9-
How to receive files:
10-
</h3>
6+
<h3 className="text-sm font-medium mb-2">How to receive files:</h3>
117
<ol className="text-xs space-y-1 list-decimal list-inside">
128
<li>Get a ticket from someone who is sharing a file</li>
139
<li>Paste the ticket in the text area above</li>

web-app/src/components/receiver/Receiver.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,12 @@ export function Receiver({ onTransferStateChange }: ReceiverProps) {
4848
}, [isReceiving, onTransferStateChange])
4949

5050
return (
51-
<div
52-
className="p-6 space-y-6 relative h-112 overflow-y-auto flex flex-col"
53-
>
51+
<div className="p-6 space-y-6 relative h-112 overflow-y-auto flex flex-col">
5452
{!isReceiving ? (
5553
<>
5654
<div className="text-center">
5755
<div className="flex items-center justify-center gap-2 mb-2">
58-
<h2
59-
className="text-xl font-semibold"
60-
>
56+
<h2 className="text-xl font-semibold">
6157
{t('common:receiver.title')}
6258
</h2>
6359
<Button

web-app/src/components/receiver/TicketInput.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ export function TicketInput({
1818
return (
1919
<div className="space-y-4">
2020
<div>
21-
<p
22-
className="block text-sm font-medium mb-2"
23-
>
21+
<p className="block text-sm font-medium mb-2">
2422
{t('common:receiver.saveToFolder')}
2523
</p>
2624
<InputGroup onClick={onBrowseFolder}>
@@ -37,9 +35,7 @@ export function TicketInput({
3735
</div>
3836

3937
<div>
40-
<p
41-
className="block text-sm font-medium mb-2"
42-
>
38+
<p className="block text-sm font-medium mb-2">
4339
{t('common:receiver.pasteTicket')}
4440
</p>
4541
<div className="flex gap-2 p-0.5">

web-app/src/components/sender/DragDrop.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ interface DragDropProps {
88
onFileSelect: (path: string) => void
99
selectedPath?: string | null
1010
isLoading?: boolean
11+
onClearSelection: () => void
1112
}
1213

1314
export function DragDrop({
1415
onFileSelect,
1516
selectedPath,
1617
isLoading,
18+
onClearSelection,
1719
}: DragDropProps) {
1820
const {
1921
isDragActive,
@@ -42,6 +44,7 @@ export function DragDrop({
4244
showFullPath={showFullPath}
4345
isLoading={isLoading || false}
4446
onToggleFullPath={toggleFullPath}
47+
onClearSelection={onClearSelection}
4548
/>
4649

4750
{!selectedPath && (

web-app/src/components/sender/Dropzone.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ChevronDown, ChevronRight, Loader2, Upload } from 'lucide-react'
1+
import { ChevronDown, ChevronRight, Loader2, Upload, X } from 'lucide-react'
22
import { useTranslation } from '../../i18n/react-i18next-compat'
33
import type { DropzoneProps } from '../../types/sender'
44
import { FolderIcon, getFileIcon } from '../illustration'
@@ -10,6 +10,7 @@ export function Dropzone({
1010
showFullPath,
1111
isLoading,
1212
onToggleFullPath,
13+
onClearSelection,
1314
}: DropzoneProps) {
1415
const { t } = useTranslation()
1516
const getDropzoneStyles = () => {
@@ -102,8 +103,21 @@ export function Dropzone({
102103
return (
103104
<div
104105
style={getDropzoneStyles()}
105-
className="border-2 border-dashed rounded-lg p-16 text-center cursor-pointer transition-all duration-200 bg-accent text-accent-foreground flex items-center justify-center min-h-48 border-border"
106+
className="relative border-2 border-dashed rounded-lg p-16 text-center cursor-pointer transition-all duration-200 bg-accent text-accent-foreground flex items-center justify-center min-h-48 border-border"
106107
>
108+
{selectedPath && !isLoading && (
109+
<button
110+
type="button"
111+
onClick={(e) => {
112+
e.stopPropagation()
113+
onClearSelection()
114+
}}
115+
className="absolute top-3 right-3 p-1.5 rounded-md text-muted-foreground cursor-pointer"
116+
aria-label="Clear selection"
117+
>
118+
<X className="h-6 w-6" />
119+
</button>
120+
)}
107121
<div className="space-y-4 w-full">
108122
<div className="flex justify-center">
109123
{isLoading ? (

web-app/src/components/sender/Sender.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export function Sender({ onTransferStateChange }: SenderProps) {
3939
isBroadcastMode,
4040
activeConnectionCount,
4141
handleFileSelect,
42+
clearSelectedPath,
4243
startSharing,
4344
stopSharing,
4445
copyTicket,
@@ -91,9 +92,7 @@ export function Sender({ onTransferStateChange }: SenderProps) {
9192
}, [viewState, isBroadcastMode, setIsBroadcastMode])
9293

9394
return (
94-
<div
95-
className="p-6 space-y-6 relative h-112 overflow-y-auto flex flex-col"
96-
>
95+
<div className="p-6 space-y-6 relative h-112 overflow-y-auto flex flex-col">
9796
{/* IDLE state: Show file selection UI */}
9897
{viewState === 'IDLE' && (
9998
<>
@@ -110,6 +109,7 @@ export function Sender({ onTransferStateChange }: SenderProps) {
110109
onFileSelect={handleFileSelect}
111110
selectedPath={selectedPath}
112111
isLoading={isLoading}
112+
onClearSelection={clearSelectedPath}
113113
/>
114114

115115
<ShareActionCard

0 commit comments

Comments
 (0)