Fill in media saved notification implementation gaps
This commit is contained in:
parent
32751aab91
commit
8738829358
|
@ -487,7 +487,7 @@ extension ConversationVC : InputViewDelegate, MessageCellDelegate, ContextMenuAc
|
|||
func save(_ viewItem: ConversationViewItem) {
|
||||
guard viewItem.canSaveMedia() else { return }
|
||||
viewItem.saveMediaAction()
|
||||
sendMediaSavedNotificationIfNeeded(with: viewItem.interaction.timestamp)
|
||||
sendMediaSavedNotificationIfNeeded(for: viewItem)
|
||||
}
|
||||
|
||||
func ban(_ viewItem: ConversationViewItem) {
|
||||
|
@ -668,12 +668,12 @@ extension ConversationVC : InputViewDelegate, MessageCellDelegate, ContextMenuAc
|
|||
*/
|
||||
}
|
||||
|
||||
func sendMediaSavedNotificationIfNeeded(with timestamp: UInt64) {
|
||||
func sendMediaSavedNotificationIfNeeded(for viewItem: ConversationViewItem) {
|
||||
// Disabled until other platforms implement it as well
|
||||
/*
|
||||
guard thread is TSContactThread else { return }
|
||||
guard thread is TSContactThread, viewItem.interaction.interactionType() == .incomingMessage else { return }
|
||||
let message = DataExtractionNotification()
|
||||
message.kind = .mediaSaved(timestamp: timestamp)
|
||||
message.kind = .mediaSaved(timestamp: viewItem.interaction.timestamp)
|
||||
Storage.write { transaction in
|
||||
MessageSender.send(message, in: self.thread, using: transaction)
|
||||
}
|
||||
|
|
|
@ -381,7 +381,16 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
|
|||
|
||||
let attachmentStream = currentViewController.galleryItem.attachmentStream
|
||||
|
||||
AttachmentSharing.showShareUI(forAttachment: attachmentStream)
|
||||
AttachmentSharing.showShareUI(forAttachment: attachmentStream) { activityType in
|
||||
guard let activityType = activityType, activityType == .saveToCameraRoll,
|
||||
let tsMessage = currentViewController.galleryItem.message as? TSIncomingMessage, let thread = tsMessage.thread as? TSContactThread else { return }
|
||||
let message = DataExtractionNotification()
|
||||
message.kind = .mediaSaved(timestamp: tsMessage.timestamp)
|
||||
Storage.write { transaction in
|
||||
MessageSender.send(message, in: thread, using: transaction)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@objc
|
||||
|
|
|
@ -110,7 +110,7 @@ extension MessageReceiver {
|
|||
private static func handleDataExtractionNotification(_ message: DataExtractionNotification, using transaction: Any) {
|
||||
let transaction = transaction as! YapDatabaseReadWriteTransaction
|
||||
guard message.groupPublicKey == nil,
|
||||
let thread = TSContactThread.getWithContactId(message.sender!, transaction: transaction), case .screenshot = message.kind else { return }
|
||||
let thread = TSContactThread.getWithContactId(message.sender!, transaction: transaction) else { return }
|
||||
let type: TSInfoMessageType
|
||||
switch message.kind! {
|
||||
case .screenshot: type = .screenshotNotification
|
||||
|
|
|
@ -6,7 +6,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
@class TSAttachmentStream;
|
||||
|
||||
typedef void (^AttachmentSharingCompletion)(void);
|
||||
typedef void (^AttachmentSharingCompletion)(UIActivityType __nullable activityType);
|
||||
|
||||
@interface AttachmentSharing : NSObject
|
||||
|
||||
|
@ -14,15 +14,14 @@ typedef void (^AttachmentSharingCompletion)(void);
|
|||
completion:(nullable AttachmentSharingCompletion)completion;
|
||||
|
||||
+ (void)showShareUIForAttachment:(TSAttachmentStream *)stream;
|
||||
+ (void)showShareUIForAttachment:(TSAttachmentStream *)stream completion:(nullable AttachmentSharingCompletion)completion;
|
||||
|
||||
+ (void)showShareUIForURL:(NSURL *)url;
|
||||
|
||||
+ (void)showShareUIForURL:(NSURL *)url completion:(nullable AttachmentSharingCompletion)completion;
|
||||
|
||||
+ (void)showShareUIForURLs:(NSArray<NSURL *> *)urls completion:(nullable AttachmentSharingCompletion)completion;
|
||||
|
||||
+ (void)showShareUIForText:(NSString *)text;
|
||||
|
||||
+ (void)showShareUIForText:(NSString *)text completion:(nullable AttachmentSharingCompletion)completion;
|
||||
|
||||
#ifdef DEBUG
|
||||
|
|
|
@ -28,7 +28,14 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
{
|
||||
OWSAssertDebug(stream);
|
||||
|
||||
[self showShareUIForURL:stream.originalMediaURL];
|
||||
[self showShareUIForAttachment:stream completion:nil];
|
||||
}
|
||||
|
||||
+ (void)showShareUIForAttachment:(TSAttachmentStream *)stream completion:(nullable AttachmentSharingCompletion)completion
|
||||
{
|
||||
OWSAssertDebug(stream);
|
||||
|
||||
[self showShareUIForURL:stream.originalMediaURL completion:completion];
|
||||
}
|
||||
|
||||
+ (void)showShareUIForURL:(NSURL *)url
|
||||
|
@ -95,7 +102,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
}
|
||||
|
||||
if (completion) {
|
||||
DispatchMainThreadSafe(completion);
|
||||
DispatchMainThreadSafe(^{ completion(activityType); });
|
||||
}
|
||||
}];
|
||||
|
||||
|
|
Loading…
Reference in New Issue