Skip to content

Commit

Permalink
fix: object deletion does not refresh file list
Browse files Browse the repository at this point in the history
  • Loading branch information
pteich committed Feb 24, 2025
1 parent b527465 commit 9d63766
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions windows/mainwindow.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,19 @@ func (mw *MainWindow) updateSelect(idx int, selected bool) {
}
}

func (mw *MainWindow) removeObject(key string) {
for idx, obj := range mw.allObjects {
if obj.Key == key {
if idx == len(mw.allObjects)-1 {
mw.allObjects = mw.allObjects[:idx]
return
}
mw.allObjects = append(mw.allObjects[:idx], mw.allObjects[idx+1:]...)
return
}
}
}

func (mw *MainWindow) updateObjectList() {
mw.currentObjects = mw.filterObjects()
mw.selectedIndex = nil
Expand Down Expand Up @@ -361,15 +374,21 @@ func (mw *MainWindow) handleDelete(ctx context.Context) {
"Delete Objects",
msg,
func(yes bool) {
if yes {
for idx := range mw.selectedIndex {
obj := mw.currentObjects[idx]
err := mw.s3svc.DeleteObject(ctx, obj.Key)
if err != nil {
dialog.ShowError(err, mw.window)
}
if !yes {
return
}

for idx := range mw.selectedIndex {
obj := mw.currentObjects[idx]
err := mw.s3svc.DeleteObject(ctx, obj.Key)
if err != nil {
dialog.ShowError(err, mw.window)
} else {
mw.removeObject(obj.Key)
}
}

mw.updateObjectList()
}, mw.window)
confirm.Show()
}
Expand Down Expand Up @@ -401,6 +420,7 @@ func (mw *MainWindow) handleUpload(ctx context.Context) {
dialog.ShowInformation("OK", "Upload finished!", mw.window)
mw.loadObjects(ctx)
}, mw.window)

fd.Show()
}

Expand Down

0 comments on commit 9d63766

Please sign in to comment.