Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Context menu entry for media view: Show in Chat #5914

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -125,7 +125,7 @@ class ConversationSplitViewController: UISplitViewController, ConversationSplit
}
}

func presentThread(_ thread: TSThread, action: ConversationViewAction, focusMessageId: String?, animated: Bool) {
func presentThread(_ thread: TSThread, action: ConversationViewAction, focusMessageId: String?, animated: Bool, forceReload: Bool = false) {
AssertIsOnMainThread()

// On iOS 13, there is a bug with UISplitViewController that causes the `isCollapsed` state to
Expand All @@ -137,14 +137,14 @@ class ConversationSplitViewController: UISplitViewController, ConversationSplit
owsFailDebug("check if this still happens")
// Reset this to avoid getting stuck in a loop. We're becoming active.
lastActiveInterfaceOrientation = windowScene.interfaceOrientation
DispatchQueue.main.async { self.presentThread(thread, action: action, focusMessageId: focusMessageId, animated: animated) }
DispatchQueue.main.async { self.presentThread(thread, action: action, focusMessageId: focusMessageId, animated: animated, forceReload: forceReload) }
return
}

if homeVC.selectedHomeTab != .chatList {
guard homeVC.presentedViewController == nil else {
homeVC.dismiss(animated: true) {
self.presentThread(thread, action: action, focusMessageId: focusMessageId, animated: animated)
self.presentThread(thread, action: action, focusMessageId: focusMessageId, animated: animated, forceReload: forceReload)
}
return
}
Expand All @@ -153,7 +153,7 @@ class ConversationSplitViewController: UISplitViewController, ConversationSplit
homeVC.selectedHomeTab = .chatList
}

guard selectedThread?.uniqueId != thread.uniqueId else {
guard ((selectedThread?.uniqueId != thread.uniqueId) || forceReload) else {
// If this thread is already selected, pop to the thread if
// anything else has been presented above the view.
guard let selectedConversationVC = selectedConversationViewController else { return }
Expand Down Expand Up @@ -684,3 +684,4 @@ extension ConversationSplitViewController: DeviceTransferServiceObserver {

func deviceTransferServiceDidRequestAppRelaunch() {}
}

2 changes: 1 addition & 1 deletion Signal/src/ViewControllers/MediaGallery/MediaGallery.swift
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ class MediaGallery {
typealias Update = Sections.Update
typealias Journal = [JournalingOrderedDictionaryChange<Sections.ItemChange>]

private let thread: TSThread
let thread: TSThread

// Used for filtering.
private(set) var mediaFilter: AllMediaFilter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,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 +503,16 @@ class MediaPageViewController: UIPageViewController {
let sender = fromNavigationBar ? barButtonShareMedia : bottomMediaPanel
AttachmentSharing.showShareUI(for: attachmentStream, sender: sender)
}

private func jumpToConversation() {
SignalApp.shared.presentConversationForThread(
mediaGallery.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 +891,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