Bugfix. Done.
This commit is contained in:
Родитель
4b58093a90
Коммит
c1e3f2b579
|
@ -210,7 +210,7 @@ extension Feed {
|
|||
return 0
|
||||
}
|
||||
|
||||
return limit - Int32(items.count)
|
||||
return max(limit - Int32(items.count), 0)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ class FeedModuleInteractor: FeedModuleInteractorInput {
|
|||
output.didFail(error: result.error!)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
let feed = Feed(query: result.query, fetchID: request.uid, feedType: request.feedType, items: result.posts, cursor: result.cursor)
|
||||
|
||||
if isLoadingMore {
|
||||
|
|
|
@ -499,13 +499,22 @@ class FeedModulePresenter: FeedModuleInput, FeedModuleViewOutput, FeedModuleInte
|
|||
|
||||
// MARK: FeedModuleInteractorOutput
|
||||
|
||||
private func shouldFullFillFeed(feed: FeedType) -> Bool {
|
||||
switch feed {
|
||||
case .single(post: _ ):
|
||||
return false
|
||||
default:
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
private func processFetchResult(feed: Feed, isMore: Bool) {
|
||||
|
||||
guard fetchRequestsInProgress.contains(feed.fetchID), feedType == feed.feedType else {
|
||||
return
|
||||
}
|
||||
|
||||
Logger.log("items arrived \(feed.items.count)")
|
||||
// print("items got \(feed.items.count) for limit \(feed.query?.limit) with cursor \(feed.query?.cursor)")
|
||||
|
||||
cursor = feed.cursor
|
||||
|
||||
|
@ -515,7 +524,8 @@ class FeedModulePresenter: FeedModuleInput, FeedModuleViewOutput, FeedModuleInte
|
|||
updateUI(with: newItems)
|
||||
|
||||
// re-fetch missing items
|
||||
if !feed.isFullfilled() {
|
||||
if !feed.isFullfilled() && shouldFullFillFeed(feed: feed.feedType) {
|
||||
// print("requesting cursor \(feed.cursor), with limit\(feed.missingItems())")
|
||||
fetchMoreItems(with: feed.cursor, limit: feed.missingItems())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,23 +43,40 @@ class PopularModuleView: UIViewController {
|
|||
return button
|
||||
}()
|
||||
|
||||
fileprivate var isLockedUI = 0 {
|
||||
fileprivate var _isLockedUI = 0 {
|
||||
didSet {
|
||||
print(_isLockedUI)
|
||||
}
|
||||
}
|
||||
fileprivate var isLockedUI: Int {
|
||||
set {
|
||||
|
||||
guard isLockedUI >= 0 else {
|
||||
isLockedUI = 0
|
||||
return
|
||||
let oldValue = _isLockedUI
|
||||
|
||||
if newValue < 0 {
|
||||
_isLockedUI = 0
|
||||
} else {
|
||||
_isLockedUI = newValue
|
||||
}
|
||||
|
||||
feedControl.isEnabled = isLockedUI == 0
|
||||
container.isUserInteractionEnabled = isLockedUI == 0
|
||||
feedControl.isEnabled = _isLockedUI == 0
|
||||
container.isUserInteractionEnabled = _isLockedUI == 0
|
||||
|
||||
if isLockedUI == 0 {
|
||||
hideHUD(in: container)
|
||||
} else {
|
||||
showHUD(in: container)
|
||||
let shouldHide = oldValue == 1 && _isLockedUI == 0
|
||||
let shouldShow = oldValue == 0 && _isLockedUI == 1
|
||||
|
||||
if shouldHide {
|
||||
hideHUD(in: view)
|
||||
}
|
||||
else if shouldShow {
|
||||
showHUD(in: view)
|
||||
}
|
||||
}
|
||||
|
||||
get {
|
||||
return _isLockedUI
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@objc private func didTapChangeLayout() {
|
||||
|
|
|
@ -34,7 +34,7 @@ class Logger {
|
|||
return components.isEmpty ? "" : components.last!
|
||||
}
|
||||
|
||||
static var logLevel: LogEvent?
|
||||
static var logLevel: LogEvent? = .development
|
||||
static var dateFormat = "HH:mm:ss"
|
||||
static var dateFormatter: DateFormatter {
|
||||
let formatter = DateFormatter()
|
||||
|
|
|
@ -47,9 +47,9 @@ class Templates {
|
|||
class func loadTopics(interval: String, cursor: Int = 0, limit: Int = 10) -> Any {
|
||||
var topics: Array<[String: Any]> = []
|
||||
|
||||
let fetchingLimit = APIConfig.wrongFeedFetching ? Random.randomInt(max: limit) : limit
|
||||
let fetchingLimit = APIConfig.wrongFeedFetching ? Random.randomInt(max: limit, min: 1) : limit
|
||||
|
||||
for i in cursor...cursor + fetchingLimit {
|
||||
for i in cursor...cursor + fetchingLimit - 1 {
|
||||
var values = ["title": interval + String(i),
|
||||
"topicHandle": interval + String(i),
|
||||
"lastUpdatedTime": Date().ISOString,
|
||||
|
|
|
@ -7,13 +7,13 @@ import XCTest
|
|||
|
||||
//Uncomment and run to test and debug API Mock
|
||||
//
|
||||
class Loop: UITestBase {
|
||||
|
||||
func testAPIMock() {
|
||||
// APIConfig.wrongResponses = true
|
||||
APIConfig.wrongFeedFetching = true
|
||||
while true {}
|
||||
}
|
||||
|
||||
}
|
||||
//class Loop: UITestBase {
|
||||
//
|
||||
// func testAPIMock() {
|
||||
//// APIConfig.wrongResponses = true
|
||||
// APIConfig.wrongFeedFetching = true
|
||||
// while true {}
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче