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.4 #103

Merged
merged 23 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8917e89
특정 language color에서 발생하는 이슈 대응
87kangsw Apr 24, 2024
31fa62a
bump ReactorKit version
87kangsw Apr 24, 2024
3acd860
bump SnapKit version
87kangsw Apr 24, 2024
672be01
bump RealmSwift version
87kangsw Apr 24, 2024
2ba4222
bump Kingfisher version
87kangsw Apr 24, 2024
704b13d
bump SwiftyBeaver version
87kangsw Apr 24, 2024
7638412
bump Kanna version
87kangsw Apr 24, 2024
b432ded
bump Firebase version
87kangsw Apr 24, 2024
95d3af8
privacy manifest 추가 - NSPrivacyAccessedAPICategoryUserDefaults & NSPr…
87kangsw Apr 24, 2024
d376294
Merge pull request #99 from 87kangsw/feature/privacy-manifest
87kangsw Apr 24, 2024
f9ec86d
Activity내 불필요한 html 파싱로직 제거
87kangsw Apr 25, 2024
e5839e8
update GitHubKit
87kangsw May 15, 2024
45383aa
change buddy's contribution view mode to daily
87kangsw May 15, 2024
ec7ec0b
Merge pull request #101 from 87kangsw/feature/fix-buddy-parsing-error
87kangsw May 15, 2024
b4e403e
release 스킴에서만 firebase 셋팅 되도록 변경
87kangsw May 15, 2024
4eae10e
realm swift 설정 오류 수정
87kangsw May 15, 2024
6512155
Merge pull request #102 from 87kangsw/feature/build-error-fix
87kangsw May 15, 2024
a922dfc
bump version number
87kangsw May 15, 2024
9a25f46
아이패드에서 로그아웃 버튼 동작하지 않는 오류 수정
87kangsw May 15, 2024
c65b6ed
bump build number
87kangsw May 15, 2024
327d414
아이패드일 때, 상단 잔디 UI 오류 수정
87kangsw May 15, 2024
77abcf2
firebase 설정을 release 스킴에만 동작하게 하면서 발생한 오류 수정 (파베 auth 오류 수정)
87kangsw May 15, 2024
8cb90ef
bump build number
87kangsw May 15, 2024
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
Prev Previous commit
Next Next commit
change buddy's contribution view mode to daily
  • Loading branch information
87kangsw committed May 15, 2024
commit 45383aadb3d188fe5bc749f593dd41a68206d366
28 changes: 16 additions & 12 deletions GitTime/Sources/CompositionRoot.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,14 @@ final class CompositionRoot {
userDefaultService: userDefaultService,
realmService: realmService)

let buddyController = configureBuddyScreen(crawlerService: crawlerService,
realmService: realmService,
userDefaultService: userDefaultService,
followService: followService,
userService: userService,
githubService: gitHubService)
let buddyController = configureBuddyScreen(
crawlerService: crawlerService,
realmService: realmService,
followService: followService,
userService: userService,
githubService: gitHubService,
keychainService: keychainService
)

let settingController = configureSettingScreen(authService: authService,
githubService: gitHubService,
Expand Down Expand Up @@ -231,10 +233,10 @@ extension CompositionRoot {
static func configureBuddyScreen(
crawlerService: GitTimeCrawlerServiceType,
realmService: RealmServiceType,
userDefaultService: UserDefaultsServiceType,
followService: FollowServiceType,
userService: UserServiceType,
githubService: GitHubServiceType
githubService: GitHubServiceType,
keychainService: KeychainServiceType
) -> BuddyViewController {

var presentFollowScreen: () -> FollowViewController
Expand All @@ -245,10 +247,12 @@ extension CompositionRoot {
return controller
}

let reactor = BuddyViewReactor(crawlerService: crawlerService,
realmService: realmService,
userDefaultService: userDefaultService,
githubService: githubService)
let reactor = BuddyViewReactor(
crawlerService: crawlerService,
realmService: realmService,
githubService: githubService,
keychainService: keychainService
)
let controller = BuddyViewController(reactor: reactor,
presentFollowScreen: presentFollowScreen)
controller.title = "Buddys"
Expand Down
10 changes: 10 additions & 0 deletions GitTime/Sources/Utils/Extensions/Date+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,13 @@ extension Date {
return now.compare(afterHour) == .orderedDescending
}
}

extension Date {
static func todayStringFormatted() -> String {
let now = Date()
let format = "yyyy-MM-dd"
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = format
return dateFormatter.string(from: now)
}
}
19 changes: 2 additions & 17 deletions GitTime/Sources/ViewControllers/Buddy/BuddyViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ final class BuddyViewController: BaseViewController, ReactorKit.View {

// MARK: Views
private let addBuddyButtonItem = UIBarButtonItem(barButtonSystemItem: .add, target: nil, action: nil)
private let modeButton = UIButton().then {
$0.setImage(UIImage(systemName: "square.grid.2x2"), for: .normal)
}
lazy var modeButtonItem = UIBarButtonItem(customView: modeButton)

private let editButton = UIBarButtonItem(barButtonSystemItem: .edit, target: nil, action: nil)

private let tableView = UITableView(frame: .zero, style: .insetGrouped).then {
Expand Down Expand Up @@ -104,7 +101,7 @@ final class BuddyViewController: BaseViewController, ReactorKit.View {
super.viewDidLoad()
self.title = "Buddys"
self.navigationItem.leftBarButtonItem = editButton
self.navigationItem.rightBarButtonItems = [addBuddyButtonItem, modeButtonItem]
self.navigationItem.rightBarButtonItems = [addBuddyButtonItem]
addNotifications()
}

Expand Down Expand Up @@ -163,11 +160,6 @@ final class BuddyViewController: BaseViewController, ReactorKit.View {

}).disposed(by: self.disposeBag)

self.modeButton.rx.tap
.map { Reactor.Action.changeViewMode }
.bind(to: reactor.action)
.disposed(by: self.disposeBag)

self.editButton.rx.tap
.subscribe(onNext: { [weak self] _ in
guard let self = self else { return }
Expand Down Expand Up @@ -204,13 +196,6 @@ final class BuddyViewController: BaseViewController, ReactorKit.View {
.bind(to: reactor.action)
.disposed(by: self.disposeBag)

reactor.state.map { $0.viewMode }
.distinctUntilChanged()
.map { $0.systemIconName }
.map { UIImage(systemName: $0) }
.bind(to: self.modeButton.rx.image(for: .normal))
.disposed(by: self.disposeBag)

reactor.state.map { $0.alreadyExistUser }
.filterNil()
.subscribe(onNext: { [weak self] (exist, userName) in
Expand Down
79 changes: 49 additions & 30 deletions GitTime/Sources/ViewControllers/Buddy/BuddyViewReactor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

import Foundation

import GitHubKit

import ReactorKit
import RxCocoa
import RxSwift
Expand Down Expand Up @@ -44,7 +46,6 @@ final class BuddyViewReactor: Reactor {
case checkUserExist(String?)
case clearCheckExist
case addGitHubUsername(String?)
case changeViewMode
case removeGitHubUsername(String?)
case toastMessage(String?)
case checkUpdate
Expand All @@ -55,7 +56,6 @@ final class BuddyViewReactor: Reactor {
enum Mutation {
case setBuddys([ContributionInfoObject])
case addBuddy(ContributionInfoObject)
case setViewMode(BuddyViewMode)
case removeBuddy(Int)
case setAlreadyExistUser((Bool, String)?)
case setToastMessage(String?)
Expand All @@ -66,7 +66,7 @@ final class BuddyViewReactor: Reactor {
struct State {
var isLoading: Bool = false
var isRefreshing: Bool = false
var viewMode: BuddyViewMode
var viewMode: BuddyViewMode = .daily
var buddys: [ContributionInfoObject] = []
var sections: [BuddySection] {
var sectionItems: [BuddySectionItem] = []
Expand All @@ -88,26 +88,24 @@ final class BuddyViewReactor: Reactor {

private let crawlerService: GitTimeCrawlerServiceType
private let realmService: RealmServiceType
private let userDefaultService: UserDefaultsServiceType
private let githubService: GitHubServiceType
fileprivate let keychainService: KeychainServiceType

let initialState: State

// MARK: Initializing
init(
crawlerService: GitTimeCrawlerServiceType,
realmService: RealmServiceType,
userDefaultService: UserDefaultsServiceType,
githubService: GitHubServiceType
githubService: GitHubServiceType,
keychainService: KeychainServiceType
) {
self.crawlerService = crawlerService
self.realmService = realmService
self.userDefaultService = userDefaultService
self.githubService = githubService
self.keychainService = keychainService

// let period: PeriodTypes = PeriodTypes(rawValue: userdefaultsService.value(forKey: UserDefaultsKey.period) ?? "") ?? PeriodTypes.daily
let viewMode = BuddyViewMode(rawValue: userDefaultService.value(forKey: UserDefaultsKey.buddyViewMode) ?? "yearly") ?? .yearly
initialState = State(viewMode: viewMode)
initialState = State()
}

// MARK: Mutate
Expand All @@ -128,10 +126,6 @@ final class BuddyViewReactor: Reactor {
let endLoading: Observable<Mutation> = .just(.setLoading(false))
let request = self.requestContribution(userName: userName)
return .concat(startLoading, request, endLoading)
case .changeViewMode:
let newViewMode: BuddyViewMode = (self.currentState.viewMode == .yearly) ? .daily : .yearly
self.userDefaultService.set(value: newViewMode.rawValue, forKey: UserDefaultsKey.buddyViewMode)
return .just(.setViewMode(newViewMode))
case .removeGitHubUsername(let userName):
guard let userName = userName else { return .empty() }

Expand Down Expand Up @@ -190,8 +184,6 @@ final class BuddyViewReactor: Reactor {
state.buddys = addedBuddys
case .setBuddys(let buddys):
state.buddys = buddys
case .setViewMode(let viewMode):
state.viewMode = viewMode
case .removeBuddy(let index):
var buddys = state.buddys
buddys.remove(at: index)
Expand Down Expand Up @@ -223,25 +215,52 @@ final class BuddyViewReactor: Reactor {
}
}

private func requestContribution(userName: String) -> Observable<Mutation> {
return self.crawlerService.fetchContributionsRawdata(userName: userName)
.map { response -> ContributionInfo in
let contributionInfo = self.parseContribution(response: response)
return contributionInfo
private func fetchContributions(userName: String) -> Observable<GraphQLResponse.UserContribution> {
guard let accessToken = keychainService.getAccessToken() 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: userName,
from: Date.todayStringFormatted(),
to: Date.todayStringFormatted()
)
observer.onNext(contribution)
observer.onCompleted()
} catch {
observer.onError(error)
}
}

return Disposables.create {}
}
}

private func requestContribution(userName: String) -> Observable<Mutation> {

return self.fetchContributions(userName: userName)
.observe(on: MainScheduler.asyncInstance)
.flatMap { [weak self] contributionInfo -> Observable<Mutation> in
guard let self = self else { return .empty() }
guard self.checkUserNameIsValid(originalName: userName,
userName: contributionInfo.userName,
additionalName: contributionInfo.additionalName) == true else { return .empty() }

return self.realmService.addBuddy(userName: contributionInfo.userName,
additionalName: contributionInfo.additionalName,
profileURL: contributionInfo.profileImageURL,
contribution: contributionInfo.contributions)
.map { buddy -> Mutation in
.addBuddy(buddy)
return self.realmService.addBuddy(
userName: contributionInfo.profile.userName ?? "",
additionalName: contributionInfo.profile.login,
profileURL: contributionInfo.profile.profileURL ?? "",
contribution: contributionInfo.contributions.map {
Contribution(
date: $0.date,
contribution: $0.contributionCount,
hexColor: $0.color
)
}
)
.map { buddy -> Mutation in
.addBuddy(buddy)
}
}
.catch { error -> Observable<Mutation> in
log.error(error.localizedDescription)
Expand Down
2 changes: 1 addition & 1 deletion project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ packages:
branch: master
GitHubKit:
url: https://github.com/87kangsw/GitHubKit
from: 1.0.1
from: 1.0.2
fileGroups:
- GitTime/Supporting Files
targets:
Expand Down
Loading