Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Release] 2.2.2 #96

Merged
merged 8 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions GitTime/Sources/CompositionRoot.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ final class CompositionRoot {

let activityController = configureActivityScreen(activityService: activityService,
userService: userService,
crawlerService: crawlerService)
crawlerService: crawlerService,
keychainService: keychainService
)

let trendController = configureTrendingScreen(crawlerService: crawlerService,
languagesService: languageService,
Expand Down Expand Up @@ -163,11 +165,14 @@ extension CompositionRoot {
static func configureActivityScreen(
activityService: ActivityServiceType,
userService: UserServiceType,
crawlerService: GitTimeCrawlerServiceType
crawlerService: GitTimeCrawlerServiceType,
keychainService: KeychainServiceType
) -> ActivityViewController {
let reactor = ActivityViewReactor(activityService: activityService,
userService: userService,
crawlerService: crawlerService)
crawlerService: crawlerService,
keychainService: keychainService
)
let controller = ActivityViewController(reactor: reactor)
controller.title = "Activity"
controller.tabBarItem.title = "Activity"
Expand Down
3 changes: 1 addition & 2 deletions GitTime/Sources/Models/Event.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ struct Event: ModelType {
repo = try container.decode(RepositoryInfo.self, forKey: .repo)
isPublic = try container.decode(Bool.self, forKey: .isPublic)
let dateString = try container.decode(String.self, forKey: .createdAt)
let df = DateFormatter()
df.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZ"
let df = ISO8601DateFormatter()
createdAt = df.date(from: dateString) ?? Date()

switch type {
Expand Down
2 changes: 2 additions & 0 deletions GitTime/Sources/Models/Me.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Foundation
struct Me: ModelType {
let id: Int
let name: String
let additionalName: String
let profileURL: String
let url: String
let bio: String?
Expand All @@ -23,6 +24,7 @@ struct Me: ModelType {
enum CodingKeys: String, CodingKey {
case id
case name = "login"
case additionalName = "name"
case profileURL = "avatar_url"
case url = "html_url"
case bio
Expand Down
3 changes: 1 addition & 2 deletions GitTime/Sources/Models/Payload.swift
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,7 @@ struct Comment: ModelType {
body = try container.decode(String.self, forKey: .body)

let dateString = try container.decode(String.self, forKey: .createdAt)
let df = DateFormatter()
df.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZ"
let df = ISO8601DateFormatter()
createdAt = df.date(from: dateString) ?? Date()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import UIKit

import GitHubKit
import Moya
import ReactorKit
import RxCocoa
Expand Down Expand Up @@ -60,17 +61,21 @@ final class ActivityViewReactor: ReactorKit.Reactor {
fileprivate let activityService: ActivityServiceType
fileprivate let userService: UserServiceType
fileprivate let crawlerService: GitTimeCrawlerServiceType
fileprivate let keychainService: KeychainServiceType

private let imageDownloder = ImageDownloader(name: "profileImageDownloder")

init(
activityService: ActivityServiceType,
userService: UserServiceType,
crawlerService: GitTimeCrawlerServiceType
crawlerService: GitTimeCrawlerServiceType,
keychainService: KeychainServiceType
) {
self.activityService = activityService
self.userService = userService
self.crawlerService = crawlerService
self.keychainService = keychainService

self.initialState = State(isLoading: false,
page: ActivityViewReactor.INITIAL_PAGE,
canLoadMore: true,
Expand Down Expand Up @@ -192,6 +197,27 @@ final class ActivityViewReactor: ReactorKit.Reactor {

guard let me = GlobalStates.shared.currentUser.value else { return .empty() }

return self.fetchContributions()
.observe(on: MainScheduler.instance)
.map { userContribution -> ContributionInfo in
return ContributionInfo(
count: userContribution.totalContributions,
contributions: userContribution.contributions.map {
Contribution(
date: $0.date,
contribution: $0.contributionCount,
hexColor: $0.color
)
},
userName: me.name,
additionalName: me.additionalName,
profileImageURL: me.profileURL
)
}
.flatMap { response -> Observable<Mutation> in
return .just(.setContributionInfo(response))
}
/*
return self.crawlerService.fetchContributionsRawdata(userName: me.name)
.map { response -> Mutation in
let contributionInfo = self.parseContribution(response: response)
Expand All @@ -203,6 +229,30 @@ final class ActivityViewReactor: ReactorKit.Reactor {
.map { contributionInfo -> Mutation in
return .setContributionInfo(contributionInfo)}
}
*/
}

private func fetchContributions() -> Observable<GraphQLResponse.UserContribution> {
guard let accessToken = keychainService.getAccessToken() else { return .empty() }
guard let me = GlobalStates.shared.currentUser.value else { return .empty() }

let githubKit = GitHubKit(config: .init(token: accessToken))

return Observable.create { observer -> Disposable in
async {
do {
let contribution = try await githubKit.contributions(userName: me.name)
observer.onNext(contribution)
observer.onCompleted()
} catch {
observer.onError(error)
}
}

return Disposables.create {

}
}
}

private func requestTrialContributions() -> Observable<Mutation> {
Expand Down
4 changes: 2 additions & 2 deletions GitTime/Sources/Views/Activity/ActivityItemCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ final class ActivityItemCell: BaseTableViewCell, ReactorKit.View {
let actorProfile = state.event.actor.profileURL
if let actorProfileURL = URL(string: actorProfile) {
let cache = ImageCache.default
cache.memoryStorage.config.expiration = .seconds(2)
authorProfileImageView.kf.setImage(with: actorProfileURL, options: [.memoryCacheExpiration(.seconds(5))])
cache.memoryStorage.config.expiration = .days(1)
authorProfileImageView.kf.setImage(with: actorProfileURL, options: [.memoryCacheExpiration(.days(1))])
}

let actorName = state.event.actor.name
Expand Down
4 changes: 2 additions & 2 deletions GitTime/Supporting Files/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.2.1</string>
<string>2.2.2</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
Expand All @@ -100,7 +100,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>9</string>
<string>10</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationQueriesSchemes</key>
Expand Down
4 changes: 4 additions & 0 deletions project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ packages:
Toaster:
url: https://github.com/devxoul/Toaster.git
branch: master
GitHubKit:
url: https://github.com/87kangsw/GitHubKit
from: 1.0.0
fileGroups:
- GitTime/Supporting Files
targets:
Expand Down Expand Up @@ -118,6 +121,7 @@ targets:
- package: Firebase
product: FirebasePerformance
- package: Toaster
- package: GitHubKit
GitTimeTests:
platform: iOS
type: bundle.unit-test
Expand Down
Loading