Skip to content

Commit

Permalink
Show read for all notis when user has not logged in:
Browse files Browse the repository at this point in the history
  • Loading branch information
manhlx3006 committed Dec 26, 2019
1 parent afbd696 commit 332d14f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class KNNotificationTableViewCell: UITableViewCell {
func updateCell(with noti: KNNotification, index: Int) {
self.iconImageView.image = UIImage(named: "noti_icon_\(noti.label)")
self.backgroundColor = {
if !noti.read { return UIColor(red: 232, green: 239, blue: 255) }
if !noti.read && IEOUserStorage.shared.user != nil { return UIColor(red: 232, green: 239, blue: 255) }
if index % 2 == 0 { return UIColor(red: 255, green: 255, blue: 255) }
return UIColor(red: 246, green: 247, blue: 251)
}()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class KNNotificationCoordinator: NSObject {
}

func markAsRead(ids: [Int], completion: @escaping (String?) -> Void) {
if ids.isEmpty {
if ids.isEmpty || IEOUserStorage.shared.user == nil {
completion(nil)
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class KNNotificationStorage {

func updateNotification(_ noti: KNNotification) {
if self.realm == nil { return }
self.realm.beginWrite()
self.realm.add([noti], update: .modified)
try! self.realm.commitWrite()
KNNotificationUtil.postNotification(for: kUpdateListNotificationsKey)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,10 @@ class KNBalanceTabHamburgerMenuViewController: KNBaseViewController {
}

@objc func notificationDidUpdate(_ sender: Any?) {
let numUnread = KNNotificationCoordinator.shared.numberUnread
let numUnread: Int = {
if IEOUserStorage.shared.user == nil { return 0 }
return KNNotificationCoordinator.shared.numberUnread
}()
self.update(notificationsCount: numUnread)
}
}
Expand Down

0 comments on commit 332d14f

Please sign in to comment.