Fixed some decoding errors
This commit is contained in:
parent
2b97df5fe1
commit
cd77852549
@ -728,7 +728,7 @@
|
|||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
|
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 53;
|
CURRENT_PROJECT_VERSION = 54;
|
||||||
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
||||||
INFOPLIST_FILE = AutoCat/Info.plist;
|
INFOPLIST_FILE = AutoCat/Info.plist;
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
|
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
|
||||||
@ -750,7 +750,7 @@
|
|||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
|
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 53;
|
CURRENT_PROJECT_VERSION = 54;
|
||||||
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
||||||
INFOPLIST_FILE = AutoCat/Info.plist;
|
INFOPLIST_FILE = AutoCat/Info.plist;
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
|
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
|
||||||
|
|||||||
@ -14,35 +14,35 @@
|
|||||||
<key>isShown</key>
|
<key>isShown</key>
|
||||||
<false/>
|
<false/>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>8</integer>
|
<integer>5</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>DifferenceKit (Playground) 2.xcscheme</key>
|
<key>DifferenceKit (Playground) 2.xcscheme</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>isShown</key>
|
<key>isShown</key>
|
||||||
<false/>
|
<false/>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>9</integer>
|
<integer>6</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>DifferenceKit (Playground).xcscheme</key>
|
<key>DifferenceKit (Playground).xcscheme</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>isShown</key>
|
<key>isShown</key>
|
||||||
<false/>
|
<false/>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>7</integer>
|
<integer>4</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>Eureka (Playground) 1.xcscheme</key>
|
<key>Eureka (Playground) 1.xcscheme</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>isShown</key>
|
<key>isShown</key>
|
||||||
<false/>
|
<false/>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>5</integer>
|
<integer>2</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>Eureka (Playground) 2.xcscheme</key>
|
<key>Eureka (Playground) 2.xcscheme</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>isShown</key>
|
<key>isShown</key>
|
||||||
<false/>
|
<false/>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>6</integer>
|
<integer>3</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>Eureka (Playground) 3.xcscheme</key>
|
<key>Eureka (Playground) 3.xcscheme</key>
|
||||||
<dict>
|
<dict>
|
||||||
@ -70,7 +70,7 @@
|
|||||||
<key>isShown</key>
|
<key>isShown</key>
|
||||||
<false/>
|
<false/>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>4</integer>
|
<integer>1</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>GettingStarted (Playground) 1.xcscheme</key>
|
<key>GettingStarted (Playground) 1.xcscheme</key>
|
||||||
<dict>
|
<dict>
|
||||||
@ -112,42 +112,42 @@
|
|||||||
<key>isShown</key>
|
<key>isShown</key>
|
||||||
<false/>
|
<false/>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>11</integer>
|
<integer>13</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>Rx (Playground) 1.xcscheme</key>
|
<key>Rx (Playground) 1.xcscheme</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>isShown</key>
|
<key>isShown</key>
|
||||||
<false/>
|
<false/>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>2</integer>
|
<integer>8</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>Rx (Playground) 2.xcscheme</key>
|
<key>Rx (Playground) 2.xcscheme</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>isShown</key>
|
<key>isShown</key>
|
||||||
<false/>
|
<false/>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>3</integer>
|
<integer>9</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>Rx (Playground).xcscheme</key>
|
<key>Rx (Playground).xcscheme</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>isShown</key>
|
<key>isShown</key>
|
||||||
<false/>
|
<false/>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>1</integer>
|
<integer>7</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>SwiftDate (Playground) 1.xcscheme</key>
|
<key>SwiftDate (Playground) 1.xcscheme</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>isShown</key>
|
<key>isShown</key>
|
||||||
<false/>
|
<false/>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>12</integer>
|
<integer>10</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>SwiftDate (Playground) 2.xcscheme</key>
|
<key>SwiftDate (Playground) 2.xcscheme</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>isShown</key>
|
<key>isShown</key>
|
||||||
<false/>
|
<false/>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>13</integer>
|
<integer>12</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>SwiftDate (Playground) 3.xcscheme</key>
|
<key>SwiftDate (Playground) 3.xcscheme</key>
|
||||||
<dict>
|
<dict>
|
||||||
@ -175,7 +175,7 @@
|
|||||||
<key>isShown</key>
|
<key>isShown</key>
|
||||||
<false/>
|
<false/>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>10</integer>
|
<integer>11</integer>
|
||||||
</dict>
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
<key>SuppressBuildableAutocreation</key>
|
<key>SuppressBuildableAutocreation</key>
|
||||||
|
|||||||
@ -74,7 +74,17 @@ class CheckController: UIViewController, UITableViewDelegate, UITextFieldDelegat
|
|||||||
if let event = event {
|
if let event = event {
|
||||||
action = .sendSpecific(event)
|
action = .sendSpecific(event)
|
||||||
}
|
}
|
||||||
self.check(number: number, action: action).subscribe().disposed(by: self.bag)
|
//self.check(number: number, action: action).subscribe().disposed(by: self.bag)
|
||||||
|
HUD.show(.progress)
|
||||||
|
self.check(number: number, action: action).subscribe { vehicle in
|
||||||
|
self.updateDetailController(with: vehicle)
|
||||||
|
HUD.hide()
|
||||||
|
} onError: { error in
|
||||||
|
HUD.hide()
|
||||||
|
self.show(error: error)
|
||||||
|
//HUD.show(error: error)
|
||||||
|
}
|
||||||
|
.disposed(by: self.bag)
|
||||||
break
|
break
|
||||||
case .addVoiceRecord:
|
case .addVoiceRecord:
|
||||||
self.tabBarController?.selectedIndex = 1
|
self.tabBarController?.selectedIndex = 1
|
||||||
@ -105,7 +115,9 @@ class CheckController: UIViewController, UITableViewDelegate, UITextFieldDelegat
|
|||||||
self.updateDetailController(with: vehicle)
|
self.updateDetailController(with: vehicle)
|
||||||
HUD.hide()
|
HUD.hide()
|
||||||
} onError: { error in
|
} onError: { error in
|
||||||
HUD.show(error: error)
|
HUD.hide()
|
||||||
|
self.show(error: error)
|
||||||
|
//HUD.show(error: error)
|
||||||
}
|
}
|
||||||
.disposed(by: self.bag)
|
.disposed(by: self.bag)
|
||||||
|
|
||||||
@ -210,7 +222,9 @@ class CheckController: UIViewController, UITableViewDelegate, UITextFieldDelegat
|
|||||||
self.updateDetailController(with: vehicle)
|
self.updateDetailController(with: vehicle)
|
||||||
HUD.hide()
|
HUD.hide()
|
||||||
} onError: { error in
|
} onError: { error in
|
||||||
HUD.show(error: error)
|
HUD.hide()
|
||||||
|
self.show(error: error)
|
||||||
|
//HUD.show(error: error)
|
||||||
}
|
}
|
||||||
.disposed(by: self.bag)
|
.disposed(by: self.bag)
|
||||||
}
|
}
|
||||||
@ -277,14 +291,24 @@ class CheckController: UIViewController, UITableViewDelegate, UITextFieldDelegat
|
|||||||
return checkSingle
|
return checkSingle
|
||||||
} else {
|
} else {
|
||||||
return checkSingle
|
return checkSingle
|
||||||
.flatMap { _ in self.getEvent(for: action) }
|
.flatMap { self.addEvent(to: $0, action: action) }
|
||||||
.flatMap { event in event.findAddress().map{ event }.catchErrorJustReturn(event) }
|
}
|
||||||
.flatMap { Api.add(event: $0, to: number) }
|
}
|
||||||
|
|
||||||
|
func addEvent(to vehicle: Vehicle, action: EventAction) -> Single<Vehicle> {
|
||||||
|
return self.getEvent(for: action).flatMap { event in
|
||||||
|
return event
|
||||||
|
.findAddress()
|
||||||
|
.map{ event }
|
||||||
|
.catchErrorJustReturn(event)
|
||||||
|
.flatMap { Api.add(event: $0, to: vehicle.freeze().getNumber()) }
|
||||||
.observeOn(MainScheduler.instance)
|
.observeOn(MainScheduler.instance)
|
||||||
.map {
|
.map {
|
||||||
try self.save(vehicle: $0)
|
try self.save(vehicle: $0)
|
||||||
return $0
|
return $0
|
||||||
}
|
}
|
||||||
|
.catchErrorJustReturn(vehicle)
|
||||||
}
|
}
|
||||||
|
.catchErrorJustReturn(vehicle)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,12 +15,7 @@ class Response<T>: Decodable where T: Decodable {
|
|||||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
success = try container.decode(Bool.self, forKey: .success)
|
success = try container.decode(Bool.self, forKey: .success)
|
||||||
if success {
|
if success {
|
||||||
do {
|
data = try container.decode(T.self, forKey: .data)
|
||||||
data = try container.decode(T.self, forKey: .data)
|
|
||||||
} catch {
|
|
||||||
print(error)
|
|
||||||
data = nil
|
|
||||||
}
|
|
||||||
error = nil
|
error = nil
|
||||||
} else {
|
} else {
|
||||||
error = try container.decode(String.self, forKey: .error)
|
error = try container.decode(String.self, forKey: .error)
|
||||||
|
|||||||
@ -162,8 +162,8 @@ class Vehicle: Object, Decodable, Identifiable, Differentiable {
|
|||||||
self.vin2 = try container.decodeIfPresent(String.self, forKey: .vin2)
|
self.vin2 = try container.decodeIfPresent(String.self, forKey: .vin2)
|
||||||
self.sts = try container.decodeIfPresent(String.self, forKey: .sts)
|
self.sts = try container.decodeIfPresent(String.self, forKey: .sts)
|
||||||
self.pts = try container.decodeIfPresent(String.self, forKey: .pts)
|
self.pts = try container.decodeIfPresent(String.self, forKey: .pts)
|
||||||
self.isRightWheel = try container.decode(RealmOptional<Bool>.self, forKey: .isRightWheel)
|
self.isRightWheel = RealmOptional(try container.decodeIfPresent(Bool.self, forKey: .isRightWheel))
|
||||||
self.isJapanese = try container.decode(RealmOptional<Bool>.self, forKey: .isJapanese)
|
self.isJapanese = RealmOptional(try container.decodeIfPresent(Bool.self, forKey: .isJapanese))
|
||||||
self.addedDate = (try container.decode(TimeInterval.self, forKey: .addedDate))/1000
|
self.addedDate = (try container.decode(TimeInterval.self, forKey: .addedDate))/1000
|
||||||
self.addedBy = try container.decode(String.self, forKey: .addedBy)
|
self.addedBy = try container.decode(String.self, forKey: .addedBy)
|
||||||
|
|
||||||
|
|||||||
@ -40,7 +40,7 @@ class Api {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return URLSession.shared.rx.data(request: request).asSingle().map { data in
|
return URLSession.shared.rx.data(request: request).asSingle().map { data in
|
||||||
let str = String(data: data, encoding: .utf8)
|
// let str = String(data: data, encoding: .utf8)
|
||||||
// print("================================")
|
// print("================================")
|
||||||
// if let string = str?.replacingOccurrences(of: "\\\"", with: "\"")
|
// if let string = str?.replacingOccurrences(of: "\\\"", with: "\"")
|
||||||
// .replacingOccurrences(of: "\\'", with: "'")
|
// .replacingOccurrences(of: "\\'", with: "'")
|
||||||
@ -48,11 +48,17 @@ class Api {
|
|||||||
// print(string)
|
// print(string)
|
||||||
// }
|
// }
|
||||||
// print("================================")
|
// print("================================")
|
||||||
let resp = try JSONDecoder().decode(Response<T>.self, from: data)
|
do {
|
||||||
if resp.success {
|
let resp = try JSONDecoder().decode(Response<T>.self, from: data)
|
||||||
return resp.data!
|
if resp.success {
|
||||||
} else {
|
return resp.data!
|
||||||
throw self.genError(resp.error!, suggestion: "")
|
} else {
|
||||||
|
throw self.genError(resp.error!, suggestion: "")
|
||||||
|
}
|
||||||
|
} catch let error as Swift.DecodingError {
|
||||||
|
throw CocoaError.error((error as CustomDebugStringConvertible).debugDescription)
|
||||||
|
} catch {
|
||||||
|
throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,9 +3,9 @@ import Foundation
|
|||||||
enum Constants {
|
enum Constants {
|
||||||
static var baseUrl: String {
|
static var baseUrl: String {
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
//return "http://127.0.0.1:3000/"
|
return "http://127.0.0.1:3000/"
|
||||||
//return "http://192.168.1.67:3000/"
|
//return "http://192.168.1.67:3000/"
|
||||||
return "https://vps.aliencat.pro:8443/"
|
//return "https://vps.aliencat.pro:8443/"
|
||||||
#else
|
#else
|
||||||
return "https://vps.aliencat.pro:8443/"
|
return "https://vps.aliencat.pro:8443/"
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user