Skip to content

Commit

Permalink
Added context menu entry in media view: Show in Chat
Browse files Browse the repository at this point in the history
  • Loading branch information
findus committed Nov 19, 2024
1 parent 5a62976 commit 542999f
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 5 deletions.
5 changes: 3 additions & 2 deletions Signal/AppLaunch/SignalApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ extension SignalApp {
_ thread: TSThread,
action: ConversationViewAction = .none,
focusMessageId: String? = nil,
animated: Bool
animated: Bool,
forceReload: Bool = false
) {
AssertIsOnMainThread()

Expand All @@ -179,7 +180,7 @@ extension SignalApp {
}
return
}
conversationSplitViewController.presentThread(thread, action: action, focusMessageId: focusMessageId, animated: animated)
conversationSplitViewController.presentThread(thread, action: action, focusMessageId: focusMessageId, animated: animated, forceReload: forceReload)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ extension ChatListViewController {
thread,
action: action,
focusMessageId: focusMessageId,
animated: animated
animated: animated,
forceReload: false
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class MediaPageViewController: UIPageViewController {
private let isShowingSingleMessage: Bool
let mediaGallery: MediaGallery
let spoilerState: SpoilerRenderState
private var thread: TSThread

private let initialGalleryItem: MediaGalleryItem

Expand All @@ -26,19 +27,22 @@ class MediaPageViewController: UIPageViewController {
initialMediaAttachment: initialMediaAttachment,
mediaGallery: MediaGallery(thread: thread, mediaCategory: .photoVideo, spoilerState: spoilerState),
spoilerState: spoilerState,
showingSingleMessage: showingSingleMessage
showingSingleMessage: showingSingleMessage,
thread: thread
)
}

init?(
initialMediaAttachment: ReferencedTSResource,
mediaGallery: MediaGallery,
spoilerState: SpoilerRenderState,
showingSingleMessage: Bool = false
showingSingleMessage: Bool = false,
thread: TSThread
) {
self.mediaGallery = mediaGallery
self.spoilerState = spoilerState
self.isShowingSingleMessage = showingSingleMessage
self.thread = thread

Logger.info("will ensureLoadedForDetailView")
guard let initialItem = mediaGallery.ensureLoadedForDetailView(focusedAttachment: initialMediaAttachment) else {
Expand Down Expand Up @@ -344,6 +348,17 @@ class MediaPageViewController: UIPageViewController {
self?.deleteCurrentMedia()
}
))

contextMenuActions.append(UIAction(
title: OWSLocalizedString(
"MEDIA_VIEWER_JUMP_TO_CONVERSATION",
comment: "Context menu item in media viewer. Jumps to position in conversation."
),
image: Theme.iconImage(.arrowUp),
handler: { [weak self] _ in
self?.jumpToConversation()
}
))
contextMenuButton.setActions(actions: contextMenuActions)
}

Expand Down Expand Up @@ -492,6 +507,16 @@ class MediaPageViewController: UIPageViewController {
let sender = fromNavigationBar ? barButtonShareMedia : bottomMediaPanel
AttachmentSharing.showShareUI(for: attachmentStream, sender: sender)
}

private func jumpToConversation() {
SignalApp.shared.presentConversationForThread(
thread,
focusMessageId: currentViewController?.galleryItem.message.uniqueId,
animated: true,
forceReload: true
)
self.dismiss(animated: false)
}

private func deleteCurrentMedia() {
guard let mediaItem = currentItem else { return }
Expand Down Expand Up @@ -870,3 +895,4 @@ extension MediaPageViewController: UINavigationBarDelegate {
dismissSelf(animated: true)
}
}

3 changes: 3 additions & 0 deletions Signal/translations/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -4168,6 +4168,9 @@
/* Context menu item in media viewer. Refers to deleting currently displayed photo/video. */
"MEDIA_VIEWER_DELETE_MEDIA_ACTION" = "Delete";

/* Context menu item in media viewer, Refers to jumping to position in conversation*/
"MEDIA_VIEWER_JUMP_TO_CONVERSATION" = "Show in Chat";

/* button title to snooze a megaphone */
"MEGAPHONE_REMIND_LATER" = "Remind Me Later";

Expand Down

0 comments on commit 542999f

Please sign in to comment.