|
1 | 1 | use crate::app::{AppAction, DesiredAppAction}; |
2 | 2 | use crate::backend_task::dashpay::DashPayTask; |
| 3 | +use crate::backend_task::error::TaskError; |
3 | 4 | use crate::backend_task::{BackendTask, BackendTaskSuccessResult}; |
4 | 5 | use crate::context::AppContext; |
5 | 6 | use crate::ui::components::dashpay_subscreen_chooser_panel::add_dashpay_subscreen_chooser_panel; |
@@ -251,8 +252,9 @@ impl ProfileSearchScreen { |
251 | 252 | } |
252 | 253 |
|
253 | 254 | pub fn display_message(&mut self, _message: &str, _message_type: MessageType) { |
254 | | - // Banner display is handled globally by AppState; this is only for side-effects. |
255 | | - self.loading = false; |
| 255 | + // Don't touch loading state here — display_message can be called for |
| 256 | + // unrelated task completions while we're waiting for search results. |
| 257 | + // Loading state is managed by search_profiles() and display_task_result(). |
256 | 258 | } |
257 | 259 | } |
258 | 260 |
|
@@ -318,10 +320,9 @@ impl ScreenLike for ProfileSearchScreen { |
318 | 320 | } |
319 | 321 |
|
320 | 322 | fn display_task_result(&mut self, result: BackendTaskSuccessResult) { |
321 | | - self.loading = false; |
322 | | - |
323 | 323 | match result { |
324 | 324 | BackendTaskSuccessResult::DashPayProfileSearchResults(results) => { |
| 325 | + self.loading = false; |
325 | 326 | self.search_results.clear(); |
326 | 327 |
|
327 | 328 | // Convert backend results to UI results |
@@ -366,8 +367,16 @@ impl ScreenLike for ProfileSearchScreen { |
366 | 367 | // Message display is handled globally by AppState |
367 | 368 | } |
368 | 369 | _ => { |
369 | | - // Ignore other results |
| 370 | + // Ignore other results — don't touch loading state for |
| 371 | + // results from unrelated tasks |
370 | 372 | } |
371 | 373 | } |
372 | 374 | } |
| 375 | + |
| 376 | + fn display_task_error(&mut self, _error: &TaskError) -> bool { |
| 377 | + // Clear loading state on error so the spinner stops. |
| 378 | + // Return false to let AppState show the default error banner. |
| 379 | + self.loading = false; |
| 380 | + false |
| 381 | + } |
373 | 382 | } |
0 commit comments