Reloading history when data changes

This commit is contained in:
Selim Mustafaev 2020-11-06 00:35:58 +03:00
parent cd77852549
commit cefb0143e5
2 changed files with 10 additions and 1 deletions

View File

@ -39,6 +39,7 @@ class CheckController: UIViewController, UITableViewDelegate, UITextFieldDelegat
}
self.history.delegate = self
NotificationCenter.default.addObserver(self, selector:#selector(self.calendarDayDidChange(_:)), name:NSNotification.Name.NSCalendarDayChanged, object:nil)
}
override func viewWillAppear(_ animated: Bool) {
@ -74,7 +75,6 @@ class CheckController: UIViewController, UITableViewDelegate, UITextFieldDelegat
if let event = event {
action = .sendSpecific(event)
}
//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)
@ -100,6 +100,10 @@ class CheckController: UIViewController, UITableViewDelegate, UITextFieldDelegat
}
}
@objc private func calendarDayDidChange(_ notification : NSNotification) {
self.historyDataSource.reload()
}
// MARK: - Checking new number
@IBAction func checkTapped(_ sender: UIButton) {

View File

@ -101,4 +101,9 @@ class RealmSectionedDataSource<Item,Cell>: NSObject, UITableViewDataSource where
func item(at indexPath: IndexPath) -> Item {
return self.sections[indexPath.section].elements[indexPath.row]
}
func reload() {
self.sections = self.data.groupedByDate()
self.tv.reloadData()
}
}