Skip to content

Commit

Permalink
Only fetch unread items on initial list download
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobsimeon authored and Jacob Morris committed Aug 31, 2021
1 parent a253660 commit 0f108d5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions PocketKit/Sources/Sync/Operations/FetchList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class FetchList: AsyncOperation {

if let updatedSince = lastRefresh.lastRefresh {
query.savedItemsFilter = SavedItemsFilter(updatedSince: updatedSince)
} else {
query.savedItemsFilter = SavedItemsFilter(status: .unread)
}

return try await apollo.fetch(query: query)
Expand Down
4 changes: 2 additions & 2 deletions PocketKit/Tests/SyncTests/Operations/FetchListTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,13 @@ class FetchListTests: XCTestCase {
XCTAssertEqual(call.query.savedItemsFilter?.updatedSince, 123456789)
}

func test_refresh_whenUpdatedSinceIsNotPresent_doesNotIncludeUpdatedSinceFilter() {
func test_refresh_whenUpdatedSinceIsNotPresent_onlyFetchesUnreadItems() {
apollo.stubFetch(toReturnFixturedNamed: "list", asResultType: UserByTokenQuery.self)

performOperation()

let call: MockApolloClient.FetchCall<UserByTokenQuery> = apollo.fetchCall(at: 0)
XCTAssertNil(call.query.savedItemsFilter)
XCTAssertEqual(call.query.savedItemsFilter?.status, .unread)
}

func test_refresh_whenResultsAreEmpty_finishesOperationSuccessfully() {
Expand Down

0 comments on commit 0f108d5

Please sign in to comment.