diff options
| author | Fuwn <[email protected]> | 2025-03-23 06:21:11 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2025-03-23 06:21:11 -0700 |
| commit | 24e425575405345959a3994984e90f4b5643a38f (patch) | |
| tree | 234b64c32688a4a2decbb3b5f599fbf3bedafb10 /Sora/Views/Post/Grid/PostGridView.swift | |
| parent | feat: Development commit (diff) | |
| download | sora-testing-24e425575405345959a3994984e90f4b5643a38f.tar.xz sora-testing-24e425575405345959a3994984e90f4b5643a38f.zip | |
feat: Development commit
Diffstat (limited to 'Sora/Views/Post/Grid/PostGridView.swift')
| -rw-r--r-- | Sora/Views/Post/Grid/PostGridView.swift | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Sora/Views/Post/Grid/PostGridView.swift b/Sora/Views/Post/Grid/PostGridView.swift index 5d08d2c..80130a4 100644 --- a/Sora/Views/Post/Grid/PostGridView.swift +++ b/Sora/Views/Post/Grid/PostGridView.swift @@ -77,6 +77,27 @@ struct PostGridView: View { updateViewState(for: queryID, currentPage: newPage) } } + .onChange(of: manager.historyIndex) { _, newIndex in + guard newIndex >= 0 && newIndex < manager.searchHistory.count else { return } + + let queryID = manager.searchHistory[newIndex].id + + if let state = viewStates[queryID] { + manager.posts = state.posts + manager.currentPage = state.currentPage + } else { + manager.posts = [] + manager.currentPage = 1 + + Task { + await manager.fetchPosts( + page: 1, + tags: manager.searchHistory[newIndex].tags, + replace: true + ) + } + } + } .toolbar { #if os(macOS) ToolbarItem { |