Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use RefreshItem to refresh an element in list #124

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/transport/bridge/recv.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (d *RecvData) OnSelected(i int) {
d.items[len(d.items)-1] = nil // Allow the GC to reclaim memory.
d.items = d.items[:len(d.items)-1]

d.list.Refresh()
d.list.RefreshItem(i)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry but this doesn't work. In this case we are changing the whole slice due to deletion and want to refresh everything.

}}

removeCard := &widget.Card{Content: container.NewVBox(removeLabel, removeButton)}
Expand Down
18 changes: 17 additions & 1 deletion internal/transport/bridge/send.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package bridge

import (
"fmt"
"path/filepath"

"fyne.io/fyne/v2"
Expand Down Expand Up @@ -43,6 +44,7 @@ type SendData struct {
Client *transport.Client
Window fyne.Window
Canvas fyne.Canvas
Uris []fyne.URI
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also seems like it shouldn't be here.


items []*SendItem
list *widget.List
Expand Down Expand Up @@ -119,7 +121,7 @@ func (d *SendData) OnSelected(i int) {
d.items[len(d.items)-1] = nil // Allow the GC to reclaim memory.
d.items = d.items[:len(d.items)-1]

d.list.Refresh()
d.list.RefreshItem(i)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here. We can't use RefreshItem() because we modify the whole slice.

}}

// Only allow failed or completed items to be removed.
Expand Down Expand Up @@ -191,6 +193,20 @@ func (d *SendData) OnFileSelect(file fyne.URIReadCloser, err error) {
}()
}

func (d *SendData) OnMultiFilesSelect(file fyne.URIReadCloser, err error) {
if err != nil {
fyne.LogError("Error on selecting file to send", err)
dialog.ShowError(err, d.Window)
return
} else if file == nil {
return
}

fmt.Println("uris before:", d.Uris)
d.Uris = append(d.Uris, file.URI())
fmt.Println("uris after:", d.Uris)
}
Comment on lines +196 to +208
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this supposed to be here?


// OnDirSelect is intended to be passed as callback to a FolderOpen dialog.
func (d *SendData) OnDirSelect(dir fyne.ListableURI, err error) {
if err != nil {
Expand Down