Skip to content

Commit 344ca53

Browse files
authored
Merge pull request #103 from 87kangsw/release/2.2.4
[Release] 2.2.4
2 parents fe01cd1 + 8cb90ef commit 344ca53

17 files changed

+161
-165
lines changed

BuildScripts/FirebaseCrashlytics.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
${BUILD_DIR%/Build/*}/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run
1+
if [ "${CONFIGURATION}" = "Release" ]; then
2+
${BUILD_DIR%/Build/*}/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run
3+
fi

GitTime/Sources/CompositionRoot.swift

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,14 @@ final class CompositionRoot {
7979
userDefaultService: userDefaultService,
8080
realmService: realmService)
8181

82-
let buddyController = configureBuddyScreen(crawlerService: crawlerService,
83-
realmService: realmService,
84-
userDefaultService: userDefaultService,
85-
followService: followService,
86-
userService: userService,
87-
githubService: gitHubService)
82+
let buddyController = configureBuddyScreen(
83+
crawlerService: crawlerService,
84+
realmService: realmService,
85+
followService: followService,
86+
userService: userService,
87+
githubService: gitHubService,
88+
keychainService: keychainService
89+
)
8890

8991
let settingController = configureSettingScreen(authService: authService,
9092
githubService: gitHubService,
@@ -126,22 +128,23 @@ final class CompositionRoot {
126128

127129
// MARK: Configure SDKs
128130
static func configureSDKs() {
129-
130-
// Firebase
131-
FirebaseApp.configure()
132-
133-
// Image Cache
134-
let cache = ImageCache.default
135-
cache.clearCache()
136-
137131
#if DEBUG
138132

139133
// SwiftyBeaver
140134
let console = ConsoleDestination()
141135
console.minLevel = .verbose
142136
log.addDestination(console)
143-
137+
138+
#else
139+
140+
// Firebase
141+
FirebaseApp.configure()
142+
144143
#endif
144+
145+
// Image Cache
146+
let cache = ImageCache.default
147+
cache.clearCache()
145148
}
146149

147150
// MARK: Configure Appearance
@@ -231,10 +234,10 @@ extension CompositionRoot {
231234
static func configureBuddyScreen(
232235
crawlerService: GitTimeCrawlerServiceType,
233236
realmService: RealmServiceType,
234-
userDefaultService: UserDefaultsServiceType,
235237
followService: FollowServiceType,
236238
userService: UserServiceType,
237-
githubService: GitHubServiceType
239+
githubService: GitHubServiceType,
240+
keychainService: KeychainServiceType
238241
) -> BuddyViewController {
239242

240243
var presentFollowScreen: () -> FollowViewController
@@ -245,10 +248,12 @@ extension CompositionRoot {
245248
return controller
246249
}
247250

248-
let reactor = BuddyViewReactor(crawlerService: crawlerService,
249-
realmService: realmService,
250-
userDefaultService: userDefaultService,
251-
githubService: githubService)
251+
let reactor = BuddyViewReactor(
252+
crawlerService: crawlerService,
253+
realmService: realmService,
254+
githubService: githubService,
255+
keychainService: keychainService
256+
)
252257
let controller = BuddyViewController(reactor: reactor,
253258
presentFollowScreen: presentFollowScreen)
254259
controller.title = "Buddys"

GitTime/Sources/Models/Trial/contributions_dark.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"count": 305,
33
"userName": "Kanz",
44
"additionalName": "87kangsw",
5-
"profileImageURL": "",
5+
"profileImageURL": "https://avatars.githubusercontent.com/u/6590255",
66
"contributions": [
77
{
88
"date": "2018-11-04",

GitTime/Sources/Models/Trial/contributions_light.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"count": 305,
33
"userName": "Kanz",
44
"additionalName": "87kangsw",
5-
"profileImageURL": "",
5+
"profileImageURL": "https://avatars.githubusercontent.com/u/6590255",
66
"contributions": [
77
{
88
"date": "2018-11-04",

GitTime/Sources/Network/GitTimeProvider.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,31 +30,31 @@ class GitTimeProvider<Target: TargetType>: MoyaProvider<Target> {
3030
.asObservable()
3131
.do(onNext: { value in
3232
let message = "SUCCESS: \(requestString) (\(value))"
33-
log.debug(message, #file, #function, line: #line)
33+
log.debug("\(message), \(#file), \(#function), line: \(#line)")
3434
}, onError: { [weak self] error in
3535
if let response = (error as? MoyaError)?.response {
3636
if let jsonObject = try? response.mapJSON(failsOnEmptyData: false) {
3737
let message = "FAILURE: \(requestString) (\(response.statusCode))\n\(jsonObject)"
38-
log.warning(message, #file, #function, line: #line)
38+
log.warning("\(message), \(#file), \(#function), line: \(#line)")
3939
if response.statusCode == 403 {
4040
self?.showErrorMessageToast("API rate limit exceeded..\nPlease wait a moment. 🙏")
4141
} else {
4242
self?.showErrorMessageToast(error.localizedDescription)
4343
}
4444
} else if let rawString = String(data: response.data, encoding: .utf8) {
4545
let message = "FAILURE: \(requestString) (\(response.statusCode))\n\(rawString)"
46-
log.warning(message, #file, #function, line: #line)
46+
log.warning("\(message), \(#file), \(#function), line: \(#line)")
4747
} else {
4848
let message = "FAILURE: \(requestString) (\(response.statusCode))"
49-
log.warning(message, #file, #function, line: #line)
49+
log.warning("\(message), \(#file), \(#function), line: \(#line)")
5050
}
5151
} else {
5252
let message = "FAILURE: \(requestString)\n\(error)"
53-
log.warning(message, #file, #function, line: #line)
53+
log.warning("\(message), \(#file), \(#function), line: \(#line)")
5454
}
5555
}, onSubscribed: {
5656
let message = "REQUEST: \(requestString)"
57-
log.debug(message, #file, #function, line: #line)
57+
log.debug("\(message), \(#file), \(#function), line: \(#line)")
5858
})
5959
}
6060

GitTime/Sources/Services/AuthService.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ final class AuthService: AuthServiceType {
9494

9595
let credential = GitHubAuthProvider.credential(withToken: accessToken.accessToken)
9696

97+
#if DEBUG
98+
observer.onNext(accessToken)
99+
observer.onCompleted()
100+
#else
97101
Auth.auth().signIn(with: credential) { (authResult, error) in
98102
if let error = error {
99103
log.error(error)
@@ -111,6 +115,7 @@ final class AuthService: AuthServiceType {
111115
observer.onCompleted()
112116
}
113117
}
118+
#endif
114119

115120
return Disposables.create {
116121

GitTime/Sources/Utils/Extensions/Date+Extensions.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,13 @@ extension Date {
7474
return now.compare(afterHour) == .orderedDescending
7575
}
7676
}
77+
78+
extension Date {
79+
static func todayStringFormatted() -> String {
80+
let now = Date()
81+
let format = "yyyy-MM-dd"
82+
let dateFormatter = DateFormatter()
83+
dateFormatter.dateFormat = format
84+
return dateFormatter.string(from: now)
85+
}
86+
}

GitTime/Sources/Utils/Extensions/Rx/UIAlertController+Rx.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,11 @@ extension UIAlertController {
7373
} else if let barButtonItem = button as? UIBarButtonItem {
7474
alertController.popoverPresentationController?.barButtonItem = barButtonItem
7575
viewController.present(alertController, animated: animated, completion: nil)
76+
} else if let vc = button as? UIViewController {
77+
alertController.popoverPresentationController?.sourceView = vc.view
78+
alertController.popoverPresentationController?.sourceRect = vc.view.frame
79+
viewController.present(alertController, animated: animated, completion: nil)
7680
}
77-
7881
}
7982
return Disposables.create {
8083
alertController.dismiss(animated: true, completion: nil)

GitTime/Sources/Utils/Extensions/UIColor+Extensions.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ extension UIColor {
1616
hexFormatted = String(hexFormatted.dropFirst())
1717
}
1818

19-
assert(hexFormatted.count == 6, "Invalid hex code used.")
19+
//assert(hexFormatted.count == 6, "Invalid hex code used.")
20+
guard hexFormatted.count == 6 else {
21+
self.init(.clear)
22+
return
23+
}
2024

2125
var rgbValue: UInt64 = 0
2226
Scanner(string: hexFormatted).scanHexInt64(&rgbValue)

GitTime/Sources/ViewControllers/Activity/ActivityViewReactor.swift

Lines changed: 1 addition & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import ReactorKit
1414
import RxCocoa
1515
import RxMoya
1616
import RxSwift
17-
import Kanna
1817
import Kingfisher
1918

2019
final class ActivityViewReactor: ReactorKit.Reactor {
@@ -301,77 +300,10 @@ final class ActivityViewReactor: ReactorKit.Reactor {
301300
return self.activityService.trialActivities()
302301
.delay(.milliseconds(300), scheduler: MainScheduler.asyncInstance)
303302
.map { events -> Mutation in
304-
return .fetchActivityMore(events, nextPage: 1, canLoadMore: false)
303+
return .fetchActivity(events, nextPage: 0, canLoadMore: false)
305304
}
306305
}
307-
308-
private func parseContribution(response: Response) -> ContributionInfo {
309-
var contributionCount: Int = 0
310-
var contributions: [Contribution] = .init()
311-
var userName: String = ""
312-
var additionalName: String = ""
313-
var profileURL: String = ""
314-
315-
if let doc = try? HTML(html: response.data, encoding: .utf8) {
316-
for rect in doc.css("td") {
317-
if var date = rect["data-date"],
318-
let dataLevel = rect["data-level"] {
319-
320-
date = date.replacingOccurrences(of: "\\", with: "")
321-
.replacingOccurrences(of: "/", with: "")
322-
.replacingOccurrences(of: "\"", with: "")
323-
324-
let colorType = ContributionHexColorTypes.allCases.first { $0.rawValue == Int(dataLevel) }
325-
if let hexString = colorType?.hexString {
326-
contributions.append(Contribution(date: date, contribution: Int(dataLevel)!, hexColor: hexString))
327-
}
328-
}
329-
}
330-
331-
332-
for count in doc.css("h2, f4 text-normal mb-2") {
333-
let decimalCharacters = CharacterSet.decimalDigits
334-
let decimalRange = count.text?.rangeOfCharacter(from: decimalCharacters)
335-
336-
if decimalRange != nil {
337-
if var countText = count.text {
338-
countText = countText.components(separatedBy: CharacterSet.decimalDigits.inverted).joined()
339-
contributionCount = Int(countText)!
340-
}
341-
}
342-
}
343-
344-
/*
345-
/html/body[@class='logged-in env-production page-responsive page-profile']/div[@class='application-main ']/main[@id='js-pjax-container']/div[@class='container-xl px-3 px-md-4 px-lg-5']/div[@class='gutter-condensed gutter-lg flex-column flex-md-row d-flex']/div[@class='flex-shrink-0 col-12 col-md-3 mb-4 mb-md-0']/div[@class='h-card mt-md-n5']/div[@class='clearfix d-flex d-md-block flex-items-center mb-4 mb-md-0']/div[@class='position-relative d-inline-block col-2 col-md-12 mr-3 mr-md-0 flex-shrink-0']/a/img[@class='avatar avatar-user width-full border color-bg-primary']/@src
346-
*/
347-
for link in doc.css("img") {
348-
if let imgClass = link["class"], imgClass == "avatar avatar-user width-full border color-bg-default" {
349-
profileURL = link["src"] ?? ""
350-
}
351-
}
352-
353-
//
354-
for span in doc.css("span") {
355-
if let itemProp = span["itemprop"], itemProp.isNotEmpty {
356-
if itemProp == "name" {
357-
userName = span.content ?? ""
358-
} else if itemProp == "additionalName" {
359-
additionalName = span.content ?? ""
360-
}
361-
}
362-
}
363-
}
364-
365-
// sort by date
366-
contributions.sort(by: { $0.date < $1.date })
367306

368-
return ContributionInfo(count: contributionCount,
369-
contributions: contributions,
370-
userName: userName,
371-
additionalName: additionalName,
372-
profileImageURL: profileURL)
373-
}
374-
375307
private func downloadProfileImage() -> Observable<Mutation> {
376308
return self.profileImageDownload()
377309
.map { image -> Mutation in

0 commit comments

Comments
 (0)