WIP: rebase for 2026-05-18 #7
@@ -400,6 +400,25 @@ func (i *jsIPN) run(jsCallbacks js.Value) {
|
||||
if n.BrowseToURL != nil {
|
||||
jsCallbacks.Call("notifyBrowseToURL", *n.BrowseToURL)
|
||||
}
|
||||
if n.FilesWaiting != nil {
|
||||
jsCallbacks.Call("notifyFilesWaiting")
|
||||
}
|
||||
if n.IncomingFiles != nil {
|
||||
files := make([]jsIncomingFile, len(n.IncomingFiles))
|
||||
for i, f := range n.IncomingFiles {
|
||||
files[i] = jsIncomingFile{
|
||||
Name: f.Name,
|
||||
Started: f.Started.UnixMilli(),
|
||||
DeclaredSize: f.DeclaredSize,
|
||||
Received: f.Received,
|
||||
}
|
||||
}
|
||||
if b, err := json.Marshal(files); err == nil {
|
||||
jsCallbacks.Call("notifyIncomingFiles", string(b))
|
||||
} else {
|
||||
log.Printf("could not marshal IncomingFiles: %v", err)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
go func() {
|
||||
@@ -927,6 +946,15 @@ func (w termWriter) Write(p []byte) (n int, err error) {
|
||||
return len(p), nil
|
||||
}
|
||||
|
||||
// jsIncomingFile is the JSON representation of an in-progress inbound file
|
||||
// transfer sent to the notifyIncomingFiles callback.
|
||||
type jsIncomingFile struct {
|
||||
Name string `json:"name"`
|
||||
Started int64 `json:"started"` // Unix milliseconds; use new Date(started) in JS
|
||||
DeclaredSize int64 `json:"declaredSize"` // -1 if unknown
|
||||
Received int64 `json:"received"` // bytes received so far
|
||||
}
|
||||
|
||||
type jsNetMap struct {
|
||||
Self jsNetMapSelfNode `json:"self"`
|
||||
Peers []jsNetMapPeerNode `json:"peers"`
|
||||
|
||||
Reference in New Issue
Block a user