Skip to content

Commit

Permalink
Merge pull request #14291 from wordpress-mobile/fix/13803-gif_search_…
Browse files Browse the repository at this point in the history
…partial_page_fails

GIF search: correctly display partial page results.
  • Loading branch information
ScoutHarris authored Jun 11, 2020
2 parents 830a0e2 + fcb863f commit 784aa0a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion WordPress/Classes/ViewRelated/Media/Tenor/TenorPageable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,16 @@ struct TenorPageable: Pageable {
static let defaultPosition: String? = nil

func next() -> Pageable? {
guard position != nil else {
guard let position = position,
let currentPosition = Int(position) else {
return nil
}

// If the last page is not full, there is no more to load (thus there is no next).
let totalPossibleResults = (currentPageIndex + 1) * itemsPerPage
let remainingPageSpace = totalPossibleResults - currentPosition

if remainingPageSpace < itemsPerPage {
return nil
}

Expand Down

0 comments on commit 784aa0a

Please sign in to comment.