-
-
Notifications
You must be signed in to change notification settings - Fork 57
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
Use RefreshItem to refresh an element in list #124
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this. I am however not sure that this is the right solution. The change to d.list.RefreshItem(i)
in this case breaks removal of items. The refresh calls on lines 28 to 42 in recv.go and line 34 in send.go are the ones that need to be updated. However, it would require keeping track of the index so it is a bit complicated to get right (especially with indexes changing when we remove items).
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) | ||
} |
There was a problem hiding this comment.
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?
@@ -43,6 +44,7 @@ type SendData struct { | |||
Client *transport.Client | |||
Window fyne.Window | |||
Canvas fyne.Canvas | |||
Uris []fyne.URI |
There was a problem hiding this comment.
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.
@@ -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) |
There was a problem hiding this comment.
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.
@@ -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) |
There was a problem hiding this comment.
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.
Closing this PR |
Description:
Fixes #99
I think only two places that
Refresh
should be replaced withRefreshItem
, otherwise the otherRefresh
es logics are used as intended.Checklist: