Skip to content

Commit

Permalink
Put sync posts result into a named tuple
Browse files Browse the repository at this point in the history
  • Loading branch information
crazytonyli committed Nov 27, 2023
1 parent 09b060a commit 5981dcf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ final class PageListViewController: AbstractPostListViewController, UIViewContro
}

@MainActor
override func syncPosts(isFirstPage: Bool) async throws -> ([AbstractPost], Bool) {
override func syncPosts(isFirstPage: Bool) async throws -> SyncPostResult {
let coreDataStack = ContextManager.shared
let filter = filterSettings.currentPostListFilter()
let author = filterSettings.shouldShowOnlyMyPosts() ? blogUserID() : nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class AbstractPostListViewController: UIViewController,
UITableViewDataSource,
NetworkAwareUI // This protocol is not in an extension so that subclasses can override noConnectionMessage()
{
typealias SyncPostResult = (posts: [AbstractPost], hasMore: Bool)

private static let postsControllerRefreshInterval = TimeInterval(300)
private static let httpErrorCodeForbidden = 403
private static let postsFetchRequestBatchSize = 10
Expand Down Expand Up @@ -476,7 +478,7 @@ class AbstractPostListViewController: UIViewController,
}

@MainActor
func syncPosts(isFirstPage: Bool) async throws -> ([AbstractPost], Bool) {
func syncPosts(isFirstPage: Bool) async throws -> SyncPostResult {
let postType = postTypeToSync()
let filter = filterSettings.currentPostListFilter()
let author = filterSettings.shouldShowOnlyMyPosts() ? blogUserID() : nil
Expand Down

1 comment on commit 5981dcf

@mokagio
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat use of typealias to get a named tuple in the function return type.

Please sign in to comment.