Revision 09f272ce
ChatSecure/Classes/View Controllers/OTRRoomOccupantsViewController.swift | ||
---|---|---|
112 | 112 |
|
113 | 113 |
self.tableView.tableHeaderView = self.tableHeaderView |
114 | 114 |
self.tableView.tableFooterView = self.tableFooterView |
115 |
updateMuteUnmuteCell()
|
|
115 |
updateNotificationSwitchCell()
|
|
116 | 116 |
|
117 | 117 |
if let room = self.room { |
118 | 118 |
let seed = room.avatarSeed |
... | ... | |
173 | 173 |
self.navigationController?.navigationBar.setBackgroundImage(self.navigationBarBackground, for: .default) |
174 | 174 |
} |
175 | 175 |
|
176 |
private func updateMuteUnmuteCell() {
|
|
177 |
var muted = false
|
|
176 |
private func updateNotificationSwitchCell() {
|
|
177 |
var notificationsEnabled = true
|
|
178 | 178 |
if let room = self.room { |
179 |
muted = room.isMuted
|
|
179 |
notificationsEnabled = !room.isMuted
|
|
180 | 180 |
} |
181 | 181 |
if let view = self.tableHeaderView?.viewWithIdentifier(identifier: OTRRoomOccupantsViewController.HeaderCellMute) as? UITableViewCell, let switchView = view.accessoryView as? UISwitch { |
182 |
switchView.setOn(muted, animated: true)
|
|
182 |
switchView.setOn(notificationsEnabled, animated: true)
|
|
183 | 183 |
} |
184 | 184 |
} |
185 | 185 |
|
... | ... | |
210 | 210 |
cell = tableView.dequeueReusableCell(withIdentifier: type) |
211 | 211 |
let muteswitch = UISwitch() |
212 | 212 |
if let room = self.room { |
213 |
muteswitch.setOn(room.isMuted, animated: false) |
|
213 |
muteswitch.setOn(!room.isMuted, animated: false)
|
|
214 | 214 |
} |
215 |
muteswitch.addTarget(self, action: #selector(self.didChangeMuteSwitch(_:)), for: .valueChanged)
|
|
215 |
muteswitch.addTarget(self, action: #selector(self.didChangeNotificationSwitch(_:)), for: .valueChanged)
|
|
216 | 216 |
cell?.accessoryView = muteswitch |
217 | 217 |
cell?.isUserInteractionEnabled = true |
218 | 218 |
cell?.selectionStyle = .none |
... | ... | |
251 | 251 |
default: break |
252 | 252 |
} |
253 | 253 |
} |
254 |
@objc func didChangeMuteSwitch(_ sender: UIControl!) {
|
|
254 |
@objc func didChangeNotificationSwitch(_ sender: UIControl!) {
|
|
255 | 255 |
if let room = self.room { |
256 | 256 |
if room.isMuted { |
257 | 257 |
room.muteExpiration = nil |
... | ... | |
261 | 261 |
OTRDatabaseManager.shared.readWriteDatabaseConnection?.asyncReadWrite({ (transaction) in |
262 | 262 |
room.save(with: transaction) |
263 | 263 |
}) |
264 |
updateMuteUnmuteCell()
|
|
264 |
updateNotificationSwitchCell()
|
|
265 | 265 |
} |
266 | 266 |
} |
267 | 267 |
|
Also available in: Unified diff