mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-20 20:23:25 +01:00
Updates older ToastView code to use error initializer
This commit is contained in:
@@ -106,12 +106,14 @@ private extension AuthenticationViewController
|
|||||||
self.signInButton.isIndicatingActivity = false
|
self.signInButton.isIndicatingActivity = false
|
||||||
}
|
}
|
||||||
|
|
||||||
case .failure(let error):
|
case .failure(let error as NSError):
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
let toastView = ToastView(text: NSLocalizedString("Failed to Log In", comment: ""), detailText: error.localizedDescription)
|
let error = error.withLocalizedFailure(NSLocalizedString("Failed to Log In", comment: ""))
|
||||||
|
|
||||||
|
let toastView = ToastView(error: error)
|
||||||
toastView.textLabel.textColor = .altPink
|
toastView.textLabel.textColor = .altPink
|
||||||
toastView.detailTextLabel.textColor = .altPink
|
toastView.detailTextLabel.textColor = .altPink
|
||||||
toastView.show(in: self.navigationController?.view ?? self.view)
|
toastView.show(in: self)
|
||||||
self.toastView = toastView
|
self.toastView = toastView
|
||||||
|
|
||||||
self.signInButton.isIndicatingActivity = false
|
self.signInButton.isIndicatingActivity = false
|
||||||
|
|||||||
@@ -180,12 +180,14 @@ private extension BrowseViewController
|
|||||||
self.loadingState = .finished(.success(()))
|
self.loadingState = .finished(.success(()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch let error as NSError
|
||||||
{
|
{
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
if self.dataSource.itemCount > 0
|
if self.dataSource.itemCount > 0
|
||||||
{
|
{
|
||||||
let toastView = ToastView(text: NSLocalizedString("Failed to Fetch Sources", comment: ""), detailText: error.localizedDescription)
|
let error = error.withLocalizedFailure(NSLocalizedString("Failed to Fetch Sources", comment: ""))
|
||||||
|
|
||||||
|
let toastView = ToastView(error: error)
|
||||||
toastView.show(in: self)
|
toastView.show(in: self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -184,13 +184,15 @@ private extension NewsViewController
|
|||||||
self.loadingState = .finished(.success(()))
|
self.loadingState = .finished(.success(()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch let error as NSError
|
||||||
{
|
{
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
if self.dataSource.itemCount > 0
|
if self.dataSource.itemCount > 0
|
||||||
{
|
{
|
||||||
let toastView = ToastView(text: NSLocalizedString("Failed to Fetch Sources", comment: ""), detailText: error.localizedDescription)
|
let error = error.withLocalizedFailure(NSLocalizedString("Failed to Fetch Sources", comment: ""))
|
||||||
toastView.show(in: self.navigationController?.view ?? self.view, duration: 2.0)
|
|
||||||
|
let toastView = ToastView(error: error)
|
||||||
|
toastView.show(in: self)
|
||||||
}
|
}
|
||||||
|
|
||||||
self.loadingState = .finished(.failure(error))
|
self.loadingState = .finished(.failure(error))
|
||||||
@@ -286,8 +288,8 @@ private extension NewsViewController
|
|||||||
{
|
{
|
||||||
case .failure(OperationError.cancelled): break // Ignore
|
case .failure(OperationError.cancelled): break // Ignore
|
||||||
case .failure(let error):
|
case .failure(let error):
|
||||||
let toastView = ToastView(text: error.localizedDescription, detailText: nil)
|
let toastView = ToastView(error: error)
|
||||||
toastView.show(in: self.navigationController?.view ?? self.view, duration: 2)
|
toastView.show(in: self)
|
||||||
|
|
||||||
case .success: print("Installed app:", storeApp.bundleIdentifier)
|
case .success: print("Installed app:", storeApp.bundleIdentifier)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -227,8 +227,8 @@ private extension PatreonViewController
|
|||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
let toastView = ToastView(text: error.localizedDescription, detailText: nil)
|
let toastView = ToastView(error: error)
|
||||||
toastView.show(in: self.navigationController?.view ?? self.view, duration: 2.0)
|
toastView.show(in: self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -250,8 +250,8 @@ private extension PatreonViewController
|
|||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
let toastView = ToastView(text: error.localizedDescription, detailText: nil)
|
let toastView = ToastView(error: error)
|
||||||
toastView.show(in: self.navigationController?.view ?? self.view, duration: 2.0)
|
toastView.show(in: self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -204,8 +204,8 @@ private extension SettingsViewController
|
|||||||
break
|
break
|
||||||
|
|
||||||
case .failure(let error):
|
case .failure(let error):
|
||||||
let toastView = ToastView(text: error.localizedDescription, detailText: nil)
|
let toastView = ToastView(error: error)
|
||||||
toastView.show(in: self.navigationController?.view ?? self.view, duration: 2.0)
|
toastView.show(in: self)
|
||||||
|
|
||||||
case .success: break
|
case .success: break
|
||||||
}
|
}
|
||||||
@@ -223,8 +223,8 @@ private extension SettingsViewController
|
|||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
if let error = error
|
if let error = error
|
||||||
{
|
{
|
||||||
let toastView = ToastView(text: error.localizedDescription, detailText: nil)
|
let toastView = ToastView(error: error)
|
||||||
toastView.show(in: self.navigationController?.view ?? self.view, duration: 2.0)
|
toastView.show(in: self)
|
||||||
}
|
}
|
||||||
|
|
||||||
self.update()
|
self.update()
|
||||||
@@ -433,7 +433,7 @@ extension SettingsViewController
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
let toastView = ToastView(text: NSLocalizedString("Cannot Send Mail", comment: ""), detailText: nil)
|
let toastView = ToastView(text: NSLocalizedString("Cannot Send Mail", comment: ""), detailText: nil)
|
||||||
toastView.show(in: self.navigationController?.view ?? self.view, duration: 2.0)
|
toastView.show(in: self)
|
||||||
}
|
}
|
||||||
|
|
||||||
case .refreshAttempts: break
|
case .refreshAttempts: break
|
||||||
@@ -450,8 +450,8 @@ extension SettingsViewController: MFMailComposeViewControllerDelegate
|
|||||||
{
|
{
|
||||||
if let error = error
|
if let error = error
|
||||||
{
|
{
|
||||||
let toastView = ToastView(text: error.localizedDescription, detailText: "")
|
let toastView = ToastView(error: error)
|
||||||
toastView.show(in: self.navigationController?.view ?? self.view, duration: 2.0)
|
toastView.show(in: self)
|
||||||
}
|
}
|
||||||
|
|
||||||
controller.dismiss(animated: true, completion: nil)
|
controller.dismiss(animated: true, completion: nil)
|
||||||
|
|||||||
Reference in New Issue
Block a user