Skip to content

Commit d53c604

Browse files
committed
fix(wait for deletion)
1 parent 439b24f commit d53c604

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

internal/ui/app_actions.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func (a *App) PerformAction(action func(id string) error, actionName string, col
4747
}
4848
}
4949

50-
time.Sleep(2 * time.Second)
50+
time.Sleep(1 * time.Second)
5151

5252
a.TviewApp.QueueUpdateDraw(func() {
5353
for _, id := range ids {
@@ -66,7 +66,7 @@ func (a *App) PerformAction(action func(id string) error, actionName string, col
6666
plural = ""
6767
}
6868
// Show success message for 3 seconds
69-
a.SetFlashMessage(fmt.Sprintf(" [#50fa7b]%s %d item%s done", actionName, len(ids), plural), 2*time.Second)
69+
a.SetFlashMessage(fmt.Sprintf(" [#50fa7b]%s %d item%s done", actionName, len(ids), plural), 1*time.Second)
7070

7171
// Clear selection on success?
7272
view.SelectedIDs = make(map[string]bool)

internal/ui/components/view/view.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,24 @@ func NewResourceView(app common.AppController, title string) *ResourceView {
288288

289289
// Update triggers a refresh with new data
290290
func (v *ResourceView) Update(headers []string, data []dao.Resource) {
291+
// Preserve items in ActionState (e.g. Deleting) if they are missing from new data
292+
// This ensures we see the red "deleting" state even if the backend removed it already
293+
if len(v.ActionStates) > 0 {
294+
newIDs := make(map[string]bool)
295+
for _, item := range data {
296+
newIDs[item.GetID()] = true
297+
}
298+
299+
for _, item := range v.RawData {
300+
id := item.GetID()
301+
if _, inAction := v.ActionStates[id]; inAction {
302+
if !newIDs[id] {
303+
data = append(data, item)
304+
}
305+
}
306+
}
307+
}
308+
291309
v.Headers = headers
292310
v.ColCount = len(headers)
293311
v.RawData = data

0 commit comments

Comments
 (0)