(currentPage string)
| 187 | } |
| 188 | |
| 189 | func (a *App) refreshVMSelection(currentPage string) { |
| 190 | // Update VM list with filtered VMs |
| 191 | a.vmList.SetVMs(models.GlobalState.FilteredVMs) |
| 192 | |
| 193 | // Update selected index if needed |
| 194 | if len(models.GlobalState.FilteredVMs) > 0 { |
| 195 | idx := 0 |
| 196 | if state, exists := models.GlobalState.SearchStates[currentPage]; exists { |
| 197 | idx = state.SelectedIndex |
| 198 | if idx < 0 || idx >= len(models.GlobalState.FilteredVMs) { |
| 199 | idx = 0 |
| 200 | } |
| 201 | |
| 202 | state.SelectedIndex = idx |
| 203 | } |
| 204 | |
| 205 | a.vmList.SetCurrentItem(idx) |
| 206 | // Manually trigger the VM changed callback to update details |
| 207 | if selectedVM := a.vmList.GetSelectedVM(); selectedVM != nil { |
| 208 | a.vmDetails.Update(selectedVM) |
| 209 | } |
| 210 | } else { |
| 211 | a.vmDetails.Clear() |
| 212 | |
| 213 | if state, exists := models.GlobalState.SearchStates[currentPage]; exists { |
| 214 | state.SelectedIndex = 0 |
| 215 | } |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | func uniqueSortedVMStatuses(vms []*api.VM) []string { |
| 220 | set := map[string]struct{}{} |
no test coverage detected