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