Skip to content

Commit 6781aa9

Browse files
authored
Update app.go
1 parent 814abfd commit 6781aa9

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

gui/app.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ func (a *App) StartSending(filePaths []string) error {
181181
"total_bytes": info.TotalBytes,
182182
"file_name": info.FileName,
183183
"peer_addr": info.PeerAddr,
184+
"peer_name": info.PeerName,
184185
"direction": "send",
185186
})
186187
},
@@ -330,7 +331,7 @@ func (a *App) ScanPeers() []PeerInfo {
330331
}
331332

332333
// ConnectToReceive connects to a peer to receive a file
333-
func (a *App) ConnectToReceive(address string) error {
334+
func (a *App) ConnectToReceive(address string, peerName string) error {
334335
downloadDir := a.settings.DownloadDir
335336
if downloadDir == "" {
336337
downloadDir = "received_files"
@@ -339,12 +340,15 @@ func (a *App) ConnectToReceive(address string) error {
339340
go func() {
340341
opts := transfer.ReceiverOptions{
341342
DownloadDir: downloadDir,
343+
PeerName: a.settings.DeviceName,
344+
SenderName: peerName,
342345
OnProgress: func(info transfer.ProgressInfo) {
343346
wailsRuntime.EventsEmit(a.ctx, "transfer:progress", map[string]interface{}{
344347
"bytes_sent": info.BytesSent,
345348
"total_bytes": info.TotalBytes,
346349
"file_name": info.FileName,
347350
"peer_addr": info.PeerAddr,
351+
"peer_name": info.PeerName,
348352
"direction": "receive",
349353
})
350354
},
@@ -353,26 +357,26 @@ func (a *App) ConnectToReceive(address string) error {
353357
_ = addHistoryEntry(HistoryEntry{
354358
FileName: fileName,
355359
Direction: "receive",
356-
PeerName: address,
360+
PeerName: peerName,
357361
Status: "completed",
358362
})
359363
wailsRuntime.EventsEmit(a.ctx, "transfer:complete", map[string]interface{}{
360364
"file_name": fileName,
361-
"peer_addr": address,
365+
"peer_addr": peerName,
362366
"direction": "receive",
363367
})
364368
},
365369
OnError: func(err error) {
366370
a.clearConn()
367371
_ = addHistoryEntry(HistoryEntry{
368372
Direction: "receive",
369-
PeerName: address,
373+
PeerName: peerName,
370374
Status: "failed",
371375
Error: err.Error(),
372376
})
373377
wailsRuntime.EventsEmit(a.ctx, "transfer:error", map[string]interface{}{
374378
"error": err.Error(),
375-
"peer_addr": address,
379+
"peer_addr": peerName,
376380
"direction": "receive",
377381
})
378382
},

0 commit comments

Comments
 (0)