Helper to get downloads for the current tab
()
| 595 | |
| 596 | // Helper to get downloads for the current tab |
| 597 | func (m RootModel) getFilteredDownloads() []*DownloadModel { |
| 598 | var filtered []*DownloadModel |
| 599 | searchLower := strings.ToLower(m.searchQuery) |
| 600 | |
| 601 | for _, d := range m.downloads { |
| 602 | // Apply tab filter first |
| 603 | switch m.activeTab { |
| 604 | case TabQueued: |
| 605 | // Queued includes paused downloads and anything not currently active or done |
| 606 | if d.done || (!d.paused && !d.pausing && (d.Speed > 0 || d.Connections > 0 || d.resuming || d.started)) { |
| 607 | continue |
| 608 | } |
| 609 | case TabActive: |
| 610 | // Active excludes paused downloads and anything without current activity |
| 611 | if d.done || d.paused || d.pausing || (d.Speed == 0 && d.Connections == 0 && !d.resuming && !d.started) { |
| 612 | continue |
| 613 | } |
| 614 | case TabDone: |
| 615 | if !d.done { |
| 616 | continue |
| 617 | } |
| 618 | } |
| 619 | |
| 620 | // Apply dashboard category filter. |
| 621 | if m.categoryFilter != "" && m.Settings != nil && config.Resolve[bool](m.Settings.Categories.CategoryEnabled) { |
| 622 | if !m.matchesCategoryFilter(d) { |
| 623 | continue |
| 624 | } |
| 625 | } |
| 626 | |
| 627 | // Apply search filter if query is set |
| 628 | if m.searchQuery != "" { |
| 629 | if !strings.Contains(d.FilenameLower, searchLower) { |
| 630 | continue |
| 631 | } |
| 632 | } |
| 633 | |
| 634 | filtered = append(filtered, d) |
| 635 | } |
| 636 | return filtered |
| 637 | } |
| 638 | |
| 639 | func (m RootModel) matchesCategoryFilter(d *DownloadModel) bool { |
| 640 | filter := m.categoryFilter |