@@ -23,10 +23,10 @@ final class PaginationCoordinator: ObservableObject {
2323 // MARK: - Pagination
2424
2525 func goToNextPage ( ) {
26- guard canSeek , let ( tab , tabIndex ) = parent . tabManager . selectedTabAndIndex else { return }
26+ guard canSeek , let ( tab , _ ) = parent . tabManager . selectedTabAndIndex else { return }
2727 let loadedRowCount = parent . tabSessionRegistry . tableRows ( for : tab . id ) . rows . count
2828 guard tab . pagination . canGoToNextPage ( loadedRowCount : loadedRowCount ) else { return }
29- paginateAfterConfirmation ( tabIndex : tabIndex ) { $0 . goToNextPage ( loadedRowCount : loadedRowCount ) }
29+ paginateAfterConfirmation ( tabId : tab . id ) { $0 . goToNextPage ( loadedRowCount : loadedRowCount ) }
3030 }
3131
3232 func goToPreviousPage ( ) {
@@ -80,9 +80,8 @@ final class PaginationCoordinator: ObservableObject {
8080 ) ,
8181 confirmTitle : String ( localized : " Show All " )
8282 ) { [ weak self ] in
83- guard let self ,
84- let tabIndex = parent . tabManager . tabs . firstIndex ( where : { $0 . id == tabId } ) else { return }
85- paginateAfterConfirmation ( tabIndex : tabIndex ) { pagination in
83+ guard let self , parent . tabManager . tabs . contains ( where : { $0 . id == tabId } ) else { return }
84+ paginateAfterConfirmation ( tabId : tabId ) { pagination in
8685 pagination . updatePageSize ( max ( total , 1 ) )
8786 pagination . goToFirstPage ( )
8887 }
@@ -116,32 +115,28 @@ final class PaginationCoordinator: ObservableObject {
116115 where condition : ( PaginationState ) -> Bool = { _ in true } ,
117116 mutate : @escaping ( inout PaginationState ) -> Void
118117 ) {
119- guard let ( tab , tabIndex ) = parent . tabManager . selectedTabAndIndex ,
118+ guard let ( tab , _ ) = parent . tabManager . selectedTabAndIndex ,
120119 condition ( tab . pagination ) else { return }
121- paginateAfterConfirmation ( tabIndex : tabIndex , mutate : mutate )
120+ paginateAfterConfirmation ( tabId : tab . id , mutate : mutate )
122121 }
123122
124123 private func paginateAfterConfirmation (
125- tabIndex : Int ,
124+ tabId : UUID ,
126125 mutate : @escaping ( inout PaginationState ) -> Void
127126 ) {
128- let tabId = parent . tabManager . tabs [ tabIndex ] . id
129- parent . confirmDiscardChangesIfNeeded ( action : . pagination ) { [ weak self ] confirmed in
127+ parent . confirmDiscardChangesIfNeeded ( forTab : tabId , action : . pagination ) { [ weak self ] confirmed in
130128 guard let self , confirmed else { return }
131129 guard parent . tabManager . mutate ( tabId : tabId , { tab in
132130 mutate ( & tab . pagination )
133131 tab . paginationVersion += 1
134132 } ) else { return }
135- reloadCurrentPage ( )
133+ reloadPage ( ofTab : tabId )
136134 }
137135 }
138136
139- private func reloadCurrentPage ( ) {
140- guard let tabIndex = parent . tabManager . selectedTabIndex ,
141- tabIndex < parent . tabManager . tabs . count else { return }
142-
143- parent . rebuildTableQuery ( at : tabIndex )
144- parent . runQuery ( viewport : . firstRow )
137+ private func reloadPage ( ofTab tabId : UUID ) {
138+ parent . rebuildTableQuery ( forTab : tabId )
139+ parent . runQuery ( onTab : tabId , viewport : . firstRow )
145140 }
146141
147142 // MARK: - Cancel Current Query
0 commit comments