Skip to content

Commit

Permalink
disable mentions-switch when notifications are disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
r10s committed Dec 9, 2024
1 parent 67e0941 commit 09fd61b
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ internal final class NotificationsViewController: UITableViewController {
NotificationManager.removeAllNotifications()
}

updateCells()
NotificationManager.updateBadgeCounters()
NotificationCenter.default.post(name: Event.messagesChanged, object: nil, userInfo: ["message_id": Int(0), "chat_id": Int(0)])
})
Expand All @@ -42,7 +43,7 @@ internal final class NotificationsViewController: UITableViewController {
private lazy var mentionsCell: SwitchCell = {
return SwitchCell(
textLabel: String.localized("pref_mention_notifications"),
on: dcContext.isMentionsEnabled(),
on: false, // set in updateCells()
action: { [weak self] cell in
self?.dcContext.setMentionsEnabled(cell.isOn)
})
Expand Down Expand Up @@ -75,6 +76,11 @@ internal final class NotificationsViewController: UITableViewController {
tableView.rowHeight = UITableView.automaticDimension
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
updateCells()
}

// MARK: - UITableViewDelegate + UITableViewDatasource
override func numberOfSections(in tableView: UITableView) -> Int {
return sections.count
Expand All @@ -95,4 +101,9 @@ internal final class NotificationsViewController: UITableViewController {
override func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? {
return sections[section].footerTitle
}

private func updateCells() {
mentionsCell.uiSwitch.isEnabled = !dcContext.isMuted()
mentionsCell.uiSwitch.isOn = !dcContext.isMuted() && dcContext.isMentionsEnabled()
}
}

0 comments on commit 09fd61b

Please sign in to comment.