Add "send to last thread" option in debug logs.

This commit is contained in:
Matthew Chen 2017-12-12 10:31:52 -05:00
parent f57c12f34d
commit 0be63d2939
2 changed files with 34 additions and 18 deletions

View File

@ -58,6 +58,14 @@
handler:^(UIAlertAction *_Nonnull action) {
[Pastelog.sharedManager sendToSelf:urlString];
}]];
[alert addAction:[UIAlertAction
actionWithTitle:
NSLocalizedString(@"DEBUG_LOG_ALERT_OPTION_SEND_TO_LAST_THREAD",
@"Label for the 'send to last thread' option of the the debug log alert.")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *_Nonnull action) {
[Pastelog.sharedManager sendToLastThread:urlString];
}]];
#endif
[alert addAction:
[UIAlertAction
@ -261,6 +269,29 @@
}];
[ThreadUtil sendMessageWithText:url inThread:thread messageSender:messageSender];
});
// Also copy to pasteboard.
[[UIPasteboard generalPasteboard] setString:url];
}
- (void)sendToLastThread:(NSString *)url
{
if (![TSAccountManager isRegistered]) {
return;
}
OWSMessageSender *messageSender = Environment.current.messageSender;
DispatchMainThreadSafe(^{
__block TSThread *thread = nil;
[[TSStorageManager sharedManager].dbReadWriteConnection
readWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
thread = [[transaction ext:TSThreadDatabaseViewExtensionName] firstObjectInGroup:[TSThread collection]];
}];
[ThreadUtil sendMessageWithText:url inThread:thread messageSender:messageSender];
});
// Also copy to pasteboard.
[[UIPasteboard generalPasteboard] setString:url];
}
@end

View File

@ -442,6 +442,9 @@
/* Label for the 'email debug log' option of the the debug log alert. */
"DEBUG_LOG_ALERT_OPTION_EMAIL" = "Email Support";
/* Label for the 'send to last thread' option of the the debug log alert. */
"DEBUG_LOG_ALERT_OPTION_SEND_TO_LAST_THREAD" = "Send to Last Thread";
/* Label for the 'send to self' option of the the debug log alert. */
"DEBUG_LOG_ALERT_OPTION_SEND_TO_SELF" = "Send to Self";
@ -637,21 +640,6 @@
/* No comment provided by engineer. */
"ERROR_MESSAGE_WRONG_TRUSTED_IDENTITY_KEY" = "Safety number changed. Tap to verify.";
/* Message for the alert indicating the 'export with signal' file had an invalid filename. */
"EXPORT_WITH_SIGNAL_ERROR_MESSAGE_INVALID_FILENAME" = "Invalid filename.";
/* Message for the alert indicating the 'export with signal' attachment couldn't be loaded. */
"EXPORT_WITH_SIGNAL_ERROR_MESSAGE_MISSING_ATTACHMENT" = "Couldn't load file.";
/* Message for the alert indicating the 'export with signal' data couldn't be loaded. */
"EXPORT_WITH_SIGNAL_ERROR_MESSAGE_MISSING_DATA" = "Couldn't load file.";
/* Message for the alert indicating the 'export with signal' file had unknown type. */
"EXPORT_WITH_SIGNAL_ERROR_MESSAGE_UNKNOWN_TYPE" = "Unknown file type.";
/* Title for the alert indicating the 'export with signal' attachment had an error. */
"EXPORT_WITH_SIGNAL_ERROR_TITLE" = "Error";
/* action sheet header when re-sending message which failed because of too many attempts */
"FAILED_SENDING_BECAUSE_RATE_LIMIT" = "Too many failures with this contact. Please try again shortly.";
@ -1384,9 +1372,6 @@
/* Label for the send button in the conversation view. */
"SEND_BUTTON_TITLE" = "Send";
/* Header title for the 'send external file' view. */
"SEND_EXTERNAL_FILE_HEADER_TITLE" = "Select a Recipient for:";
/* Title for the 'send external file' view. */
"SEND_EXTERNAL_FILE_VIEW_TITLE" = "Send File";