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

[Hotfix] 2.2.3 #97

Merged
merged 4 commits into from
Apr 14, 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
16 changes: 16 additions & 0 deletions GitTime/Sources/Models/Me.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,20 @@ struct Me: ModelType {
case followers
case following
}

init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)

id = try container.decode(Int.self, forKey: .id)
name = try container.decode(String.self, forKey: .name)
additionalName = try container.decodeIfPresent(String.self, forKey: .additionalName) ?? ""
profileURL = try container.decodeIfPresent(String.self, forKey: .profileURL) ?? ""
url = try container.decode(String.self, forKey: .url)
bio = try? container.decode(String.self, forKey: .bio)
location = try? container.decode(String.self, forKey: .location)
publicRepos = try? container.decode(Int.self, forKey: .publicRepos)
privateRepos = try? container.decode(Int.self, forKey: .privateRepos)
followers = try? container.decode(Int.self, forKey: .followers)
following = try? container.decode(Int.self, forKey: .following)
}
}
5 changes: 5 additions & 0 deletions GitTime/Sources/Services/ActivityService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ class ActivityService: ActivityServiceType {
func fetchActivities(userName: String, page: Int) -> Observable<[Event]> {
return self.networking.request(.activityEvent(userName: userName, page: page))
.map([Event].self)
.do(onError: { error in
if let decodingErrorInfo = error.decodingErrorInfo {
log.error(decodingErrorInfo)
}
})
.asObservable()
}

Expand Down
79 changes: 79 additions & 0 deletions GitTime/Sources/Utils/GitTimeDecodingError.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
//
// GitTimeDecodingError.swift
// GitTime
//
// Created by Kanz on 4/13/24.
//

// https://gist.github.com/nunogoncalves/4852077f4e576872f72b70d9e79942f3

import Foundation

import Moya

extension Error {
var decodingErrorInfo: DecodingErrorInfomation? {
if let moyaError = self as? MoyaError {
if case .objectMapping(let error, let response) = moyaError {
if let decodeError = error as? DecodingError,
let path = response.request?.url?.getPath() {
return DecodingErrorInfomation(
path: path,
error: GitTimeDecodingError(with: decodeError)
)
}
}
}
return nil
}
}

struct DecodingErrorInfomation {
let path: String
let error: GitTimeDecodingError
}

enum GitTimeDecodingError: CustomStringConvertible {
case dataCorrupted(_ message: String)
case keyNotFound(_ message: String)
case typeMismatch(_ message: String)
case valueNotFound(_ message: String)
case any(_ error: Error)

init(with error: DecodingError) {
switch error {
case let .dataCorrupted(context):
let debugDescription = (context.underlyingError as NSError?)?.userInfo["NSDebugDescription"] ?? ""
self = .dataCorrupted("Data corrupted. \(context.debugDescription) \(debugDescription)")
case let .keyNotFound(key, context):
self = .keyNotFound("Key not found. Expected -> \(key.stringValue) <- at: \(context.prettyPath())")
case let .typeMismatch(_, context):
self = .typeMismatch("Type mismatch. \(context.debugDescription), at: \(context.prettyPath())")
case let .valueNotFound(_, context):
self = .valueNotFound("Value not found. -> \(context.prettyPath()) <- \(context.debugDescription)")
default:
self = .any(error)
}
}
var description: String {
switch self {
case let .dataCorrupted(message), let .keyNotFound(message), let .typeMismatch(message), let .valueNotFound(message):
return message
case let .any(error):
return error.localizedDescription
}
}
}

extension DecodingError.Context {
func prettyPath(separatedBy separator: String = ".") -> String {
codingPath.map { $0.stringValue }.joined(separator: ".")
}
}

extension URL {
func getPath() -> String? {
let components = URLComponents(url: self, resolvingAgainstBaseURL: false)
return components?.path
}
}
2 changes: 0 additions & 2 deletions GitTime/Sources/ViewControllers/Login/LoginViewReactor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
// Copyright © 2019 KanzDevelop. All rights reserved.
//

import FirebaseRemoteConfig
import ReactorKit
import RxCocoa
import RxSwift
Expand All @@ -33,7 +32,6 @@ final class LoginViewReactor: Reactor {
fileprivate let authService: AuthServiceType
fileprivate let keychainService: KeychainServiceType
fileprivate let userService: UserServiceType
var remoteConfig: RemoteConfig!

init(authService: AuthServiceType,
keychainService: KeychainServiceType,
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.2</string>
<string>2.2.3</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
Expand All @@ -100,7 +100,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>10</string>
<string>11</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationQueriesSchemes</key>
Expand Down
4 changes: 2 additions & 2 deletions project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: GitTime
options:
bundleIdPrefix: io.github.87kangsw
deploymentTarget:
iOS: '13.0'
iOS: '14.0'
usesTabs: true
indentWidth: 4
tabWidth: 4
Expand Down Expand Up @@ -66,7 +66,7 @@ targets:
GitTime:
platform: iOS
type: application
deploymentTarget: '13.0'
deploymentTarget: '14.0'
entitilements:
path: GitTime/Supporting Files/GitTime.entitlements
scheme:
Expand Down
Loading