Skip to content

Commit 9c751fe

Browse files
committed
Merge branch 'hotfix/trending_avatar'
2 parents bdb9f1d + a86650f commit 9c751fe

File tree

5 files changed

+33
-6
lines changed

5 files changed

+33
-6
lines changed

GitTime.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,7 +1526,7 @@
15261526
"$(inherited)",
15271527
"@executable_path/Frameworks",
15281528
);
1529-
MARKETING_VERSION = 1.3.0;
1529+
MARKETING_VERSION = 1.3.1;
15301530
PRODUCT_BUNDLE_IDENTIFIER = io.github.87kangsw.GitTime;
15311531
PRODUCT_NAME = "$(TARGET_NAME)";
15321532
SWIFT_VERSION = 5.0;
@@ -1548,7 +1548,7 @@
15481548
"$(inherited)",
15491549
"@executable_path/Frameworks",
15501550
);
1551-
MARKETING_VERSION = 1.3.0;
1551+
MARKETING_VERSION = 1.3.1;
15521552
PRODUCT_BUNDLE_IDENTIFIER = io.github.87kangsw.GitTime;
15531553
PRODUCT_NAME = "$(TARGET_NAME)";
15541554
SWIFT_VERSION = 5.0;

GitTime/Sources/ViewControllers/Activity/ActivityViewController.swift

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class ActivityViewController: BaseViewController, StoryboardView, ReactorBased {
2727
return contributionView
2828
}()
2929
var filterButton: UIBarButtonItem!
30+
private let refreshControl = UIRefreshControl()
3031

3132
// MARK: - Properties
3233
static var dataSource: RxTableViewSectionedReloadDataSource<ActivitySection> {
@@ -67,11 +68,13 @@ class ActivityViewController: BaseViewController, StoryboardView, ReactorBased {
6768

6869
tableView.registerNib(cellType: ActivityItemCell.self)
6970
tableView.registerNib(cellType: EmptyTableViewCell.self)
70-
71+
7172
tableView.backgroundColor = .background
7273
tableView.separatorColor = .underLine
7374
tableView.tableFooterView = UIView()
7475

76+
tableView.refreshControl = refreshControl
77+
7578
let width: CGFloat = UIScreen.main.bounds.width
7679

7780
contributionHeaderView.snp.makeConstraints { make in
@@ -103,15 +106,25 @@ class ActivityViewController: BaseViewController, StoryboardView, ReactorBased {
103106
.bind(to: reactor.action)
104107
.disposed(by: self.disposeBag)
105108

109+
refreshControl.rx.controlEvent(.valueChanged)
110+
.map { Reactor.Action.refresh }
111+
.bind(to: reactor.action)
112+
.disposed(by: self.disposeBag)
113+
106114
// State
107115
reactor.state.map { $0.isLoading }
108116
.bind(to: loadingIndicator.rx.isAnimating)
109117
.disposed(by: self.disposeBag)
110118

119+
reactor.state.map { $0.isRefreshing }
120+
.distinctUntilChanged()
121+
.bind(to: refreshControl.rx.isRefreshing)
122+
.disposed(by: self.disposeBag)
123+
111124
reactor.state.map { $0.sectionItems }
112125
.bind(to: tableView.rx.items(dataSource: dataSource))
113126
.disposed(by: self.disposeBag)
114-
127+
115128
reactor.state.map { $0.contributionInfo }
116129
.filterNil()
117130
.take(1)

GitTime/Sources/ViewControllers/Activity/ActivityViewReactor.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ final class ActivityViewReactor: Reactor {
2020
enum Action {
2121
case firstLoad
2222
case loadMoreActivities
23+
case refresh
2324
}
2425

2526
enum Mutation {
@@ -29,10 +30,12 @@ final class ActivityViewReactor: Reactor {
2930
case fetchActivityMore([Event], nextPage: Int, canLoadMore: Bool)
3031
case setPage(Int)
3132
case setLoadMore(Bool)
33+
case setRefreshing(Bool)
3234
}
3335

3436
struct State {
3537
var isLoading: Bool = false
38+
var isRefreshing: Bool = false
3639
var page: Int = 1
3740
var canLoadMore: Bool = true
3841
var contributionInfo: ContributionInfo?
@@ -80,6 +83,15 @@ final class ActivityViewReactor: Reactor {
8083
let disableLoadMore: Observable<Mutation> = .just(.setLoadMore(false))
8184
let requestMoreActivityMuation: Observable<Mutation> = self.requestMoreActivities()
8285
return .concat([disableLoadMore, requestMoreActivityMuation])
86+
case .refresh:
87+
guard !self.currentState.isLoading else { return .empty() }
88+
guard !self.currentState.isRefreshing else { return .empty() }
89+
let clearPagingMutation = self.clearPaging()
90+
let startRefreshing: Observable<Mutation> = .just(.setRefreshing(true))
91+
let endRefreshing: Observable<Mutation> = .just(.setRefreshing(false))
92+
let requestContributionMutation = self.requestContributions()
93+
let requestActivityMutation = self.requestActivities()
94+
return .concat([clearPagingMutation, startRefreshing, requestContributionMutation, requestActivityMutation, endRefreshing])
8395
}
8496
}
8597

@@ -89,6 +101,8 @@ final class ActivityViewReactor: Reactor {
89101
switch mutation {
90102
case let .setLoading(isLoading):
91103
state.isLoading = isLoading
104+
case let .setRefreshing(isRefreshing):
105+
state.isRefreshing = isRefreshing
92106
case let .setPage(page):
93107
state.page = page
94108
case let .setLoadMore(canLoadMore):

GitTime/Sources/ViewControllers/Trend/TrendViewReactor.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ final class TrendViewReactor: Reactor {
214214
let name = item.xpath(".//div[@class='d-sm-flex flex-auto']/div[@class='col-sm-8 d-md-flex']/div[@class='col-md-6'][1]/h1")
215215
let username = item.xpath(".//div[@class='d-sm-flex flex-auto']/div[@class='col-sm-8 d-md-flex']/div[@class='col-md-6'][1]/p")
216216
let url = "https://github.com"
217-
let avatar = item.xpath(".//div[@class='mx-3']/a/img[@class='rounded-1']/@src")
217+
let avatar = item.xpath(".//div[@class='mx-3']/a/img[@class='rounded-1 avatar-user']/@src")
218218
let repoName = item.xpath(".//h1[@class='h4 lh-condensed']")
219219
let repoURL = item.xpath(".//h1[@class='h4 lh-condensed']/a/@href")
220220
let repoDescription = item.xpath(".//div[@class='f6 text-gray mt-1']")

Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,4 +279,4 @@ SPEC CHECKSUMS:
279279

280280
PODFILE CHECKSUM: 4aee58e7a538e3f38bebcdc9cb32d29de257465d
281281

282-
COCOAPODS: 1.8.4
282+
COCOAPODS: 1.9.2

0 commit comments

Comments
 (0)