Conversation
… reply notification content extensions. (cherry picked from commit 07026687dbf3214417992ee1c3a19e1da48d7a90)
(cherry picked from commit ac54c92cfd5decefdabe7cf6ea32095ed248e10a)
(cherry picked from commit 8a9bb25874edf688314f45e32e8a0e52b94fcbfa)
(cherry picked from commit f2b085294f4990e60000f902b1187ce444734509)
(cherry picked from commit 33db5b07b10644c62f6f3bc8185953fef52264c6)
Signal/ConversationView/ConversationViewController+GestureRecognizers.swift
Outdated
Show resolved
Hide resolved
|
FWIW, there are a lot of changes in this diff that are unrelated to the meaningful change, which is to build and pass along a quoted reply model. Those changes (e.g., renaming methods, restructuring methods without functional change) make it harder to review the change and verify that it's correct/safe. Generally, it's easier for us to accept changes that only touch the required lines. |
(cherry picked from commit c73f420f1ee491a92b1bd04310e9c87f6c4d6033)
|
I made those extra changes because it was pretty difficult to keep track of what indentation level that I was in, so I flattened out the nested calls. It makes it easier to read and modify in the future, but at a cost of more time to QA it. |
|
I understand, and I don't disagree that working with this code is tricky. At the same time, it's now difficult for me to verify that something subtle hasn't changed in the functionality. For example, there are now a lot of unnecessary calls to I'd appreciate if, now that we understand what the desired change is here, we could reset the refactoring and keep only the changes related to fetching and using a |
|
Yeah, I can do that! I'll undo the renamings and the restructurings and focus just on the bits that need to change to still implement the feature. Since I now know how the final code turned out it should be easy to do. I'll go get to work on it! |
(cherry picked from commit d02ce213bacdeb5e859c2178b39ece28f0a250fe)
…t needs to be changed. (cherry picked from commit eb9cc8c14d445a2db5e0c1a7aadba6a68b0b1676)
|
@sashaweiss-signal Just made the changes. Let me know what you think! |
| }.then(on: DispatchQueue.global()) { (notificationMessage: NotificationMessage) -> Promise<(DraftQuotedReplyModel?, NotificationMessage)> in | ||
| return getDraftQuotedReplyModelTupleFromIncomingMessage(notificationMessage: notificationMessage) | ||
| }.then(on: DispatchQueue.global()) { (informationTuple: (draft: DraftQuotedReplyModel?, notificationMessage: NotificationMessage)) -> Promise<(DraftQuotedReplyModel.ForSending?, NotificationMessage)> in | ||
| return getDraftQuotedReplyModelForSendingTupleFromDraftAndIncomingMessage(optionalDraftModel: informationTuple.draft, notificationMessage: informationTuple.notificationMessage) | ||
| }.then(on: DispatchQueue.global()) { (informationTuple: (draft: DraftQuotedReplyModel.ForSending?, notificationMessage: NotificationMessage)) -> Promise<Void> in |
There was a problem hiding this comment.
There's no need for these to be their own Promises. We can construct the reply inline here:
...
let thread = notificationMessage.thread
let interaction = notificationMessage.interaction
let draftQuotedReplyModelForSending = try SKEnvironment.shared.databaseStorageRef.read { tx -> DraftQuotedReplyModel.ForSending? in
if
let incomingMessage = interaction as? TSIncomingMessage,
let draftQuotedReplyModel = DependenciesBridge.shared.quotedReplyManager.buildDraftQuotedReply(originalMessage: incomingMessage, tx: txasV2Read)
{
return try DependenciesBridge.shared.quotedReplyManager.prepareDraftForSending(draftQuotedReplyModel)
}
return nil
}There was a problem hiding this comment.
IIRC If you put DependenciesBridge.shared.quotedReplyManager.prepareDraftForSending inside of a SSKEnvironment.shared.databaseStorageRef.read or SSKEnvironment.shared.databaseStorageRef.write block it will cause a database reentrant error because prepareDraftForSending is also reading from the database.
There was a problem hiding this comment.
Ah, annoying. Then something like:
...
let thread = notificationMessage.thread
let interaction = notificationMessage.interaction
let draftQuotedReplyModel = try SKEnvironment.shared.databaseStorageRef.read { tx -> DraftQuotedReplyModel? in
if let incomingMessage = interaction as? TSIncomingMessage {
return DependenciesBridge.shared.quotedReplyManager.buildDraftQuotedReply(originalMessage: incomingMessage, tx: txasV2Read)
}
return nil
}
let draftQuotedReplyModelForSending = try draftQuotedReplyModel.map { try DependenciesBridge.shared.quotedReplyManager.prepareDraftForSending($0) }There was a problem hiding this comment.
I see you already did something similar, thanks.
(cherry picked from commit 5104770e25498869993428a39adeaea4b5ee91f9)
|
Thanks for making this PR much easier to review. I'll work on getting it merged internally! |
|
This has been merged internally as |
First time contributor checklist
Contributor checklist
Description
This pull request
fixes #5898by allowing users to see which message they quick replied to. Previously before this PR users were not able to see the message that they replied to by using quick reply in the Notification Content Extension. I tested this PR by performing this user requested feature to make sure that it functioned as laid out in the user issue ticket.QuickReply.mov