add flag to disable unsend request for now
This commit is contained in:
parent
940e09c25b
commit
76a96c31bf
|
@ -555,6 +555,10 @@ extension ConversationVC : InputViewDelegate, MessageCellDelegate, ContextMenuAc
|
|||
}
|
||||
|
||||
func delete(_ viewItem: ConversationViewItem) {
|
||||
if (!self.isUnsendRequesEnabled) {
|
||||
viewItem.deleteAction()
|
||||
return
|
||||
}
|
||||
|
||||
func showInputAccessoryView() {
|
||||
UIView.animate(withDuration: 0.25, animations: {
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
// • Photo rounding (the small corners don't have the correct rounding)
|
||||
// • Remaining search glitchiness
|
||||
|
||||
final class ConversationVC : BaseVC, ConversationViewModelDelegate, OWSConversationSettingsViewDelegate, ConversationSearchControllerDelegate, UITableViewDataSource, UITableViewDelegate {
|
||||
final class ConversationVC : BaseVC, ConversationViewModelDelegate, OWSConversationSettingsViewDelegate, ConversationSearchControllerDelegate, UITableViewDataSource, UITableViewDelegate {
|
||||
let isUnsendRequesEnabled = false // Switch this to true if unsend request is done on all platforms
|
||||
let thread: TSThread
|
||||
let focusedMessageID: String? // This isn't actually used ATM
|
||||
var unreadViewItems: [ConversationViewItem] = []
|
||||
|
|
|
@ -136,6 +136,8 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType);
|
|||
- (void)deleteLocallyAction;
|
||||
- (void)deleteRemotelyAction;
|
||||
|
||||
- (void)deleteAction; // Remove this after the unsend request is enabled
|
||||
|
||||
- (BOOL)canCopyMedia;
|
||||
- (BOOL)canSaveMedia;
|
||||
|
||||
|
|
|
@ -1031,6 +1031,50 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
|
|||
|
||||
}
|
||||
|
||||
// Remove this after the unsend request is enabled
|
||||
- (void)deleteAction
|
||||
{
|
||||
[LKStorage writeWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
||||
[self.interaction removeWithTransaction:transaction];
|
||||
if (self.interaction.interactionType == OWSInteractionType_OutgoingMessage) {
|
||||
[LKStorage.shared cancelPendingMessageSendJobIfNeededForMessage:self.interaction.timestamp using:transaction];
|
||||
}
|
||||
}];
|
||||
|
||||
if (self.isGroupThread) {
|
||||
TSGroupThread *groupThread = (TSGroupThread *)self.interaction.thread;
|
||||
|
||||
// Only allow deletion on incoming and outgoing messages
|
||||
OWSInteractionType interationType = self.interaction.interactionType;
|
||||
if (interationType != OWSInteractionType_IncomingMessage && interationType != OWSInteractionType_OutgoingMessage) return;
|
||||
|
||||
// Make sure it's an open group message
|
||||
TSMessage *message = (TSMessage *)self.interaction;
|
||||
if (!message.isOpenGroupMessage) return;
|
||||
|
||||
// Get the open group
|
||||
SNOpenGroupV2 *openGroupV2 = [LKStorage.shared getV2OpenGroupForThreadID:groupThread.uniqueId];
|
||||
if (openGroup == nil && openGroupV2 == nil) return;
|
||||
|
||||
// If it's an incoming message the user must have moderator status
|
||||
if (self.interaction.interactionType == OWSInteractionType_IncomingMessage) {
|
||||
NSString *userPublicKey = [LKStorage.shared getUserPublicKey];
|
||||
if (openGroupV2 != nil) {
|
||||
if (![SNOpenGroupAPIV2 isUserModerator:userPublicKey forRoom:openGroupV2.room onServer:openGroupV2.server]) { return; }
|
||||
}
|
||||
}
|
||||
|
||||
// Delete the message
|
||||
BOOL wasSentByUser = (interationType == OWSInteractionType_OutgoingMessage);
|
||||
if (openGroupV2 != nil) {
|
||||
[[SNOpenGroupAPIV2 deleteMessageWithServerID:message.openGroupServerMessageID fromRoom:openGroupV2.room onServer:openGroupV2.server].catch(^(NSError *error) {
|
||||
// Roll back
|
||||
[self.interaction save];
|
||||
}) retainUntilComplete];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)hasBodyTextActionContent
|
||||
{
|
||||
return self.hasBodyText && self.displayableBodyText.fullText.length > 0;
|
||||
|
|
Loading…
Reference in New Issue