CR: weak capture and clearer comments

// FREEBIE
pull/1/head
Michael Kirk 7 years ago
parent debd556e09
commit 44678e3951

@ -36,11 +36,15 @@ class DebugUINotifications: DebugUIPage {
}
var sectionItems = [
OWSTableItem(title:"Last Incoming Message") {
Logger.info("\(self.logTag) scheduling notification for incoming message.")
self.delayedNotificationDispatch {
Logger.info("\(self.logTag) dispatching")
TSStorageManager.shared().newDatabaseConnection().read({ (transaction) in
OWSTableItem(title:"Last Incoming Message") { [weak self] in
guard let strongSelf = self else {
return
}
Logger.info("\(strongSelf.logTag) scheduling notification for incoming message.")
strongSelf.delayedNotificationDispatch {
Logger.info("\(strongSelf.logTag) dispatching")
TSStorageManager.shared().newDatabaseConnection().read { (transaction) in
guard let viewTransaction = transaction.ext(TSMessageDatabaseViewExtensionName) as? YapDatabaseViewTransaction else {
owsFail("unable to build view transaction")
return
@ -55,28 +59,40 @@ class DebugUINotifications: DebugUIPage {
owsFail("last message was not an incoming message.")
return
}
Logger.info("\(self.logTag) notifying user of incoming message")
self.notificationsManager.notifyUser(for: incomingMessage, in: thread, contactsManager: self.contactsManager, transaction: transaction)
})
Logger.info("\(strongSelf.logTag) notifying user of incoming message")
strongSelf.notificationsManager.notifyUser(for: incomingMessage, in: thread, contactsManager: strongSelf.contactsManager, transaction: transaction)
}
}
}
]
if let contactThread = thread as? TSContactThread {
sectionItems += [
OWSTableItem(title:"Call Missed") {
self.delayedNotificationDispatchWithFakeCall(thread: contactThread) { call in
self.notificationsAdapter.presentMissedCall(call, callerName: thread.name())
OWSTableItem(title:"Call Missed") { [weak self] in
guard let strongSelf = self else {
return
}
strongSelf.delayedNotificationDispatchWithFakeCall(thread: contactThread) { call in
strongSelf.notificationsAdapter.presentMissedCall(call, callerName: thread.name())
}
},
OWSTableItem(title:"Call Rejected: New Safety Number") {
self.delayedNotificationDispatchWithFakeCall(thread: contactThread) { call in
self.notificationsAdapter.presentMissedCallBecauseOfNewIdentity(call: call, callerName: thread.name())
OWSTableItem(title:"Call Rejected: New Safety Number") { [weak self] in
guard let strongSelf = self else {
return
}
strongSelf.delayedNotificationDispatchWithFakeCall(thread: contactThread) { call in
strongSelf.notificationsAdapter.presentMissedCallBecauseOfNewIdentity(call: call, callerName: thread.name())
}
},
OWSTableItem(title:"Call Rejected: No Longer Verified") {
self.delayedNotificationDispatchWithFakeCall(thread: contactThread) { call in
self.notificationsAdapter.presentMissedCallBecauseOfNoLongerVerifiedIdentity(call: call, callerName: thread.name())
OWSTableItem(title:"Call Rejected: No Longer Verified") { [weak self] in
guard let strongSelf = self else {
return
}
strongSelf.delayedNotificationDispatchWithFakeCall(thread: contactThread) { call in
strongSelf.notificationsAdapter.presentMissedCallBecauseOfNoLongerVerifiedIdentity(call: call, callerName: thread.name())
}
}
]

@ -221,8 +221,11 @@ extension String {
return nil
}
// Notifications strip anything that looks lik a printf formatting character,
// so literal "%" must be escaped in order to appear in notification text.
// iOS strips anything that looks like a printf formatting character from
// the notification body, so if we want to dispay a literal "%" in a notification
// it must be escaped.
// see https://developer.apple.com/documentation/uikit/uilocalnotification/1616646-alertbody
// for more details.
return text.replacingOccurrences(of: "%", with: "%%")
}

Loading…
Cancel
Save