From ae76c806aea3bc6dfe3efbf2bc3e6155f1345fdc Mon Sep 17 00:00:00 2001 From: Vlad Date: Tue, 18 Aug 2020 15:19:19 +0300 Subject: [PATCH] Fix scrollview offset and request crash --- .../PaginationDataLoadingModel.swift | 8 ++- .../PaginationWrapper.swift | 50 ++++++++++++------- .../DataLoading/RxNetworkOperationModel.swift | 1 + 3 files changed, 41 insertions(+), 18 deletions(-) diff --git a/Sources/Classes/DataLoading/PaginationDataLoading/PaginationDataLoadingModel.swift b/Sources/Classes/DataLoading/PaginationDataLoading/PaginationDataLoadingModel.swift index a74d00e7..3629c057 100644 --- a/Sources/Classes/DataLoading/PaginationDataLoading/PaginationDataLoadingModel.swift +++ b/Sources/Classes/DataLoading/PaginationDataLoading/PaginationDataLoadingModel.swift @@ -67,7 +67,9 @@ public final class PaginationDataLoadingModel= self.bottom { + let newContentOffset = CGPoint(x: 0, y: scrollView.contentOffset.y + retryViewHeight) + scrollView.setContentOffset(newContentOffset, animated: true) + + if #available(iOS 13, *) { + scrollView.setContentOffset(newContentOffset, animated: true) + } + } } } } @@ -303,19 +317,21 @@ final public class PaginationWrapper Driver in - if applicationCurrentyActive.value { + .asObservable() + .observeOn(MainScheduler.asyncInstance) + .flatMap { [applicationCurrentlyActive] state -> Observable in + if applicationCurrentlyActive.value { return .just(state) } else { - return applicationCurrentyActive + return applicationCurrentlyActive .asObservable() .filter { $0 } .delay(0.5, scheduler: MainScheduler.instance) - .asDriver(onErrorJustReturn: true) + .asObservable() .replace(with: state) } } - .drive(stateChanged) + .bind(to: stateChanged) .disposed(by: disposeBag) } @@ -329,13 +345,13 @@ final public class PaginationWrapper: Net func requestResult(from dataSource: DataSourceType) { currentRequestDisposable = dataSource .resultSingle() + .observeOn(MainScheduler.instance) .subscribe(onSuccess: { [weak self] result in self?.onGot(result: result, from: dataSource) }, onError: { [weak self] error in