Skip to content
Snippets Groups Projects
Commit 245f1d05 authored by Joscha's avatar Joscha
Browse files

Moved refresh to the background for compatibility reasons with iOS 11

parent 3c5a28d2
Branches
Tags
No related merge requests found
......@@ -48,7 +48,7 @@ class InboxViewController: UITableViewController, InboxCellDelegator {
tableView.sectionFooterHeight = 0
self.refreshControl?.addTarget(self, action: #selector(InboxViewController.refresh(_:)), for: UIControlEvents.valueChanged)
self.refreshControl?.attributedTitle = NSAttributedString(string: "Pull to refresh")
self.refreshControl?.attributedTitle = NSAttributedString(string: NSLocalizedString("PullToRefresh", comment: "Pull to refresh"))
lastUpdateLabel.sizeToFit()
lastUpdateLabel.backgroundColor = UIColor.clear
......@@ -79,11 +79,10 @@ class InboxViewController: UITableViewController, InboxCellDelegator {
})
}
func refresh(_ refreshControl: UIRefreshControl) {
func refresh(_ refreshControl: UIRefreshControl?) {
lastUpdateText = NSLocalizedString("Updating", comment: "Getting new data")
let folder = DataHandler.handler.findFolder(with: UserManager.backendInboxFolderPath)
AppDelegate.getAppDelegate().mailHandler.updateFolder(folder: folder, newMailCallback: addNewMail, completionCallback: getMailCompleted)
}
// TODO @Olli: Remove this function when MailHandler is cleaned up
......@@ -105,7 +104,8 @@ class InboxViewController: UITableViewController, InboxCellDelegator {
tableView.reloadData()
if lastUpdate == nil || Date().timeIntervalSince(lastUpdate!) > 50 {
self.refreshControl?.beginRefreshingManually()
// self.refreshControl?.beginRefreshingManually()
refresh(nil)
}
}
......
......@@ -9,12 +9,14 @@
import UIKit
import Foundation
extension UIRefreshControl {
func beginRefreshingManually() {
if let scrollView = superview as? UIScrollView {
scrollView.setContentOffset(CGPoint(x: 0, y: scrollView.contentOffset.y - frame.height), animated: true)
}
beginRefreshing()
sendActions(for: UIControlEvents.valueChanged)
}
}
//extension UIRefreshControl {
// func beginRefreshingManually() {
// if #available(iOS 11, *) {
// } else if let scrollView = superview as? UIScrollView {
// scrollView.setContentOffset(CGPoint(x: 0, y: scrollView.contentOffset.y - frame.height), animated: true)
// }
// beginRefreshing()
// sendActions(for: UIControlEvents.valueChanged)
// }
//}
......@@ -178,6 +178,7 @@
"copied" = "Schloss wurde kopiert";
"copyKey" = "Schloss in Zwischenablage kopieren";
"NeverUpdated" = "Fehler bei Aktualisierung";
"PullToRefresh" = "Aktualisieren";
"Invitation.Code.Title" = "Fast geschafft!";
"Invitation.Code.Message" = "Deine Nachricht wurde versendet.\nUm sie lesen zu können, braucht man den unterstehenden Code.\nDu kannst den Code per SMS oder Messenger teilen\n\nCode: %@";
"Invitation.Code.Share" = "Teilen";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment