Adds ability to view details of record errors in SyncResultViewController
Also updates error handling to match revised Harmony errors.
This commit is contained in:
parent
38ae10db78
commit
86beaaaaa4
@ -227,11 +227,11 @@
|
||||
<rect key="frame" x="0.0" y="611" width="375" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="bwW-PG-BcV" id="RNA-99-evH">
|
||||
<rect key="frame" x="0.0" y="0.0" width="341" height="43.5"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="349" height="43.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Service" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="4U1-fe-PIb">
|
||||
<rect key="frame" x="16" y="12" width="54" height="19.5"/>
|
||||
<rect key="frame" x="15" y="12" width="54" height="19.5"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="16"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
@ -254,11 +254,11 @@
|
||||
<rect key="frame" x="0.0" y="655" width="375" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="JPg-6O-DRe" id="zcZ-QR-Nno">
|
||||
<rect key="frame" x="0.0" y="0.0" width="341" height="43.5"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="349" height="43.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Status" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="1u0-gh-zP7">
|
||||
<rect key="frame" x="16" y="0.0" width="324" height="43.5"/>
|
||||
<rect key="frame" x="15" y="0.0" width="325" height="43.5"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
@ -278,11 +278,11 @@
|
||||
<rect key="frame" x="0.0" y="755" width="375" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="SSL-t4-QZj" id="hQB-Iy-bzy">
|
||||
<rect key="frame" x="0.0" y="0.0" width="341" height="43.5"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="349" height="43.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="App Icon Shortcuts" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="c5i-qG-ir9">
|
||||
<rect key="frame" x="16" y="0.0" width="324" height="43.5"/>
|
||||
<rect key="frame" x="15" y="0.0" width="325" height="43.5"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
@ -882,7 +882,7 @@
|
||||
<!--Record Sync Status View Controller-->
|
||||
<scene sceneID="GG8-80-sV4">
|
||||
<objects>
|
||||
<tableViewController id="kBh-Lp-rBr" customClass="RecordSyncStatusViewController" customModule="Delta" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<tableViewController storyboardIdentifier="recordSyncStatusViewController" id="kBh-Lp-rBr" customClass="RecordSyncStatusViewController" customModule="Delta" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="static" style="grouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" id="k6O-hT-4zC">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
|
||||
@ -411,8 +411,7 @@ private extension GamesViewController
|
||||
switch result
|
||||
{
|
||||
case .success: toastView = RSTToastView(text: NSLocalizedString("Sync Complete", comment: ""), detailText: nil)
|
||||
case .failure(let error as HarmonyError): toastView = RSTToastView(text: NSLocalizedString("Sync Failed", comment: ""), detailText: error.failureReason)
|
||||
case .failure(let error): toastView = RSTToastView(text: NSLocalizedString("Sync Failed", comment: ""), detailText: error.localizedDescription)
|
||||
case .failure(let error): toastView = RSTToastView(text: NSLocalizedString("Sync Failed", comment: ""), detailText: error.failureReason)
|
||||
}
|
||||
|
||||
toastView.addTarget(self, action: #selector(GamesViewController.presentSyncResultsViewController), for: .touchUpInside)
|
||||
|
||||
@ -55,8 +55,17 @@ class GameSyncStatusViewController: UITableViewController
|
||||
|
||||
let recordedObject = self.dataSource.item(at: indexPath) as! SyncableManagedObject
|
||||
|
||||
do
|
||||
{
|
||||
let records = try SyncManager.shared.recordController.fetchRecords(for: [recordedObject])
|
||||
|
||||
let recordSyncStatusViewController = segue.destination as! RecordSyncStatusViewController
|
||||
recordSyncStatusViewController.recordedObject = recordedObject
|
||||
recordSyncStatusViewController.record = records.first
|
||||
}
|
||||
catch
|
||||
{
|
||||
print(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -35,7 +35,6 @@ extension RecordSyncStatusViewController
|
||||
|
||||
class RecordSyncStatusViewController: UITableViewController
|
||||
{
|
||||
var recordedObject: SyncableManagedObject!
|
||||
var record: Record<NSManagedObject>?
|
||||
|
||||
private let dateFormatter: DateFormatter = {
|
||||
@ -85,16 +84,6 @@ private extension RecordSyncStatusViewController
|
||||
{
|
||||
func update()
|
||||
{
|
||||
do
|
||||
{
|
||||
let records = try SyncManager.shared.recordController.fetchRecords(for: [self.recordedObject])
|
||||
self.record = records.first
|
||||
}
|
||||
catch
|
||||
{
|
||||
print(error)
|
||||
}
|
||||
|
||||
if let record = self.record
|
||||
{
|
||||
self.syncingEnabledSwitch.isEnabled = !record.isConflicted
|
||||
|
||||
@ -242,7 +242,7 @@ private extension RecordVersionsViewController
|
||||
|
||||
guard let indexPath = self._selectedVersionIndexPath else { return }
|
||||
|
||||
func finish(_ result: Result<Record<NSManagedObject>>)
|
||||
func finish<T: Error>(_ result: Result<AnyRecord, T>)
|
||||
{
|
||||
DispatchQueue.main.async {
|
||||
|
||||
|
||||
@ -84,7 +84,7 @@ extension SyncManager
|
||||
|
||||
self.isAuthenticated = true
|
||||
}
|
||||
catch let error as _AuthenticationError where error.code == .noSavedCredentials
|
||||
catch AuthenticationError.noSavedCredentials
|
||||
{
|
||||
// Ignore
|
||||
}
|
||||
|
||||
@ -47,7 +47,7 @@ extension SyncResultViewController
|
||||
|
||||
class SyncResultViewController: UITableViewController
|
||||
{
|
||||
private(set) var result: Result<[Record<NSManagedObject>: Result<Void>]>!
|
||||
private(set) var result: Result<[Record<NSManagedObject>: Result<Void, RecordError>], SyncError>!
|
||||
|
||||
private lazy var dataSource = self.makeDataSource()
|
||||
|
||||
@ -70,11 +70,23 @@ class SyncResultViewController: UITableViewController
|
||||
|
||||
self.tableView.dataSource = self.dataSource
|
||||
}
|
||||
|
||||
override func prepare(for segue: UIStoryboardSegue, sender: Any?)
|
||||
{
|
||||
guard segue.identifier == "showRecordStatus" else { return }
|
||||
|
||||
guard let cell = sender as? UITableViewCell, let indexPath = self.tableView.indexPath(for: cell) else { return }
|
||||
|
||||
guard let recordError = self.dataSource.item(at: indexPath).value as? RecordError else { return }
|
||||
|
||||
let recordSyncStatusViewController = segue.destination as! RecordSyncStatusViewController
|
||||
recordSyncStatusViewController.record = recordError.record
|
||||
}
|
||||
}
|
||||
|
||||
extension SyncResultViewController
|
||||
{
|
||||
class func make(result: Result<[Record<NSManagedObject>: Result<Void>]>) -> UINavigationController
|
||||
class func make(result: Result<[Record<NSManagedObject>: Result<Void, RecordError>], SyncError>) -> UINavigationController
|
||||
{
|
||||
let storyboard = UIStoryboard(name: "SyncResultsViewController", bundle: nil)
|
||||
|
||||
@ -169,7 +181,7 @@ private extension SyncResultViewController
|
||||
errors.append(error)
|
||||
}
|
||||
}
|
||||
catch SyncError.cancelled
|
||||
catch SyncError.other(.cancelled)
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
@ -326,4 +338,15 @@ extension SyncResultViewController
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -> IndexPath?
|
||||
{
|
||||
let section = self.sortedErrors[indexPath.section]
|
||||
|
||||
switch section.group
|
||||
{
|
||||
case .other: return nil
|
||||
default: return indexPath
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,6 +52,7 @@
|
||||
<connections>
|
||||
<outlet property="errorLabel" destination="gzf-2D-v9F" id="QL8-uA-FvI"/>
|
||||
<outlet property="nameLabel" destination="E5a-nn-ak9" id="iBv-cv-b6G"/>
|
||||
<segue destination="Cj8-UD-irg" kind="show" identifier="showRecordStatus" id="bKJ-Fa-4lQ"/>
|
||||
</connections>
|
||||
</tableViewCell>
|
||||
</prototypes>
|
||||
@ -73,6 +74,14 @@
|
||||
</objects>
|
||||
<point key="canvasLocation" x="365.60000000000002" y="-179.46026986506749"/>
|
||||
</scene>
|
||||
<!--recordSyncStatusViewController-->
|
||||
<scene sceneID="rqP-Wm-wlP">
|
||||
<objects>
|
||||
<viewControllerPlaceholder storyboardName="Settings" referencedIdentifier="recordSyncStatusViewController" id="Cj8-UD-irg" sceneMemberID="viewController"/>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="xWn-zn-1t0" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="1177" y="-179"/>
|
||||
</scene>
|
||||
<!--Navigation Controller-->
|
||||
<scene sceneID="d6h-g9-dij">
|
||||
<objects>
|
||||
|
||||
2
External/Harmony
vendored
2
External/Harmony
vendored
@ -1 +1 @@
|
||||
Subproject commit 7f28cf57b0f68a26e342d392c94de18b29db9acd
|
||||
Subproject commit 3ac5af8d95bc9c9be04ddcc0da471b532366f4e4
|
||||
Loading…
Reference in New Issue
Block a user