toggleAutoRefresh toggles the auto-refresh functionality on/off.
()
| 8 | |
| 9 | // toggleAutoRefresh toggles the auto-refresh functionality on/off. |
| 10 | func (a *App) toggleAutoRefresh() { |
| 11 | uiLogger := models.GetUILogger() |
| 12 | |
| 13 | if a.autoRefreshEnabled { |
| 14 | // Disable auto-refresh |
| 15 | a.stopAutoRefresh() |
| 16 | a.autoRefreshEnabled = false |
| 17 | a.footer.UpdateAutoRefreshStatus(false) |
| 18 | a.header.ShowSuccess("Auto-refresh disabled") |
| 19 | uiLogger.Debug("Auto-refresh disabled by user") |
| 20 | } else { |
| 21 | // * Check if there are any pending operations before enabling auto-refresh |
| 22 | if models.GlobalState.HasPendingOperations() { |
| 23 | a.showMessageSafe("Cannot enable auto-refresh while there are pending operations in progress") |
| 24 | return |
| 25 | } |
| 26 | // Enable auto-refresh |
| 27 | a.autoRefreshEnabled = true |
| 28 | a.startAutoRefresh() |
| 29 | a.footer.UpdateAutoRefreshStatus(true) |
| 30 | a.header.ShowSuccess("Auto-refresh enabled (10s interval)") |
| 31 | uiLogger.Debug("Auto-refresh enabled by user") |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | // startAutoRefresh starts the auto-refresh timer. |
| 36 | func (a *App) startAutoRefresh() { |
no test coverage detected