Skip to content

Commit

Permalink
Remove multi-photo display
Browse files Browse the repository at this point in the history
  • Loading branch information
fanyu committed Mar 25, 2022
1 parent ddbead9 commit efb5fe2
Show file tree
Hide file tree
Showing 21 changed files with 37 additions and 1,005 deletions.
38 changes: 2 additions & 36 deletions Mixin.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -735,10 +735,9 @@ class ConversationViewController: UIViewController {
let isImageOrVideo = message.category.hasSuffix("_IMAGE") || message.category.hasSuffix("_VIDEO")
let mediaStatusIsReady = message.mediaStatus == MediaStatus.DONE.rawValue || message.mediaStatus == MediaStatus.READ.rawValue
if let quoteMessageId = viewModel.message.quoteMessageId, !quoteMessageId.isEmpty, let quote = cell.quotedMessageViewIfLoaded, quote.bounds.contains(recognizer.location(in: quote)) {
let messageId = messageIdIfIncluedInStackedPhotoMessage(for: quoteMessageId)
if let indexPath = dataSource?.indexPath(where: { $0.messageId == messageId }) {
if let indexPath = dataSource?.indexPath(where: { $0.messageId == quoteMessageId }) {
quotingMessageId = message.messageId
scheduleCellBackgroundFlash(messageId: messageId)
scheduleCellBackgroundFlash(messageId: quoteMessageId)
tableView.scrollToRow(at: indexPath, at: .middle, animated: true)
} else if MessageDAO.shared.hasMessage(id: quoteMessageId) {
quotingMessageId = message.messageId
Expand Down Expand Up @@ -822,9 +821,6 @@ class ConversationViewController: UIViewController {
conversationInputViewController.dismiss()
let vc = StickerPreviewViewController.instance(message: message)
vc.presentAsChild(of: self)
} else if message.category == MessageCategory.STACKED_PHOTO.rawValue {
let vc = StackedPhotoPreviewViewController(conversationId: conversationId, stackedPhotoMessage: message)
vc.presentAsChild(of: self)
} else {
conversationInputViewController.dismiss()
}
Expand Down Expand Up @@ -865,7 +861,7 @@ class ConversationViewController: UIViewController {
cell.messageContentView.frame.origin.x = 0
}
if shouldQuote, let viewModel = cell.viewModel {
conversationInputViewController.quote = (messageIfIncludedInStackedPhotoMessage(for: viewModel.message), viewModel.thumbnail)
conversationInputViewController.quote = (viewModel.message, viewModel.thumbnail)
}
case .cancelled, .failed:
tableView.isScrollEnabled = true
Expand Down Expand Up @@ -1308,7 +1304,7 @@ extension ConversationViewController: MultipleSelectionActionViewDelegate {
func multipleSelectionActionViewDidTapAction(_ view: MultipleSelectionActionView) {
switch view.intent {
case .forward:
let messages = dataSource.selectedMessageViewModels
let messages = dataSource.selectedViewModels.values
.map({ $0.message })
.sorted(by: { $0.createdAt < $1.createdAt })
let containsTranscriptMessage = messages.contains {
Expand All @@ -1331,7 +1327,7 @@ extension ConversationViewController: MultipleSelectionActionViewDelegate {
present(alert, animated: true, completion: nil)
}
case .delete:
let viewModels = dataSource.selectedMessageViewModels
let viewModels = dataSource.selectedViewModels.values.map({ $0 })
let controller = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
if !viewModels.contains(where: { $0.message.userId != myUserId || !$0.message.canRecall }) {
controller.addAction(UIAlertAction(title: Localized.ACTION_DELETE_EVERYONE, style: .destructive, handler: { (_) in
Expand Down Expand Up @@ -1891,8 +1887,6 @@ extension ConversationViewController {
actions = [.delete]
} else if category == MessageCategory.MESSAGE_RECALL.rawValue {
actions = [.delete]
} else if category == MessageCategory.STACKED_PHOTO.rawValue {
actions = [.reply, .forward, .delete]
} else {
actions = []
}
Expand All @@ -1909,7 +1903,6 @@ extension ConversationViewController {
index = nil
}
if let index = index {
let message = messageIfIncludedInStackedPhotoMessage(for: message)
let action: MessageAction = pinnedMessageIds.contains(message.messageId) ? .unpin : .pin
actions.insert(action, at: index)
}
Expand Down Expand Up @@ -1939,7 +1932,7 @@ extension ConversationViewController {
case .forward:
beginMultipleSelection(on: indexPath, intent: .forward)
case .reply:
conversationInputViewController.quote = (messageIfIncludedInStackedPhotoMessage(for: message), viewModel.thumbnail)
conversationInputViewController.quote = (message, viewModel.thumbnail)
case .addToStickers:
if message.category.hasSuffix("_STICKER"), let stickerId = message.stickerId {
StickerAPI.addSticker(stickerId: stickerId, completion: { (result) in
Expand All @@ -1960,9 +1953,9 @@ extension ConversationViewController {
case .report:
report(conversationId: conversationId, message: message)
case .pin:
SendMessageService.shared.sendPinMessages(items: [messageIfIncludedInStackedPhotoMessage(for: message)], conversationId: conversationId, action: .pin)
SendMessageService.shared.sendPinMessages(items: [message], conversationId: conversationId, action: .pin)
case .unpin:
SendMessageService.shared.sendPinMessages(items: [messageIfIncludedInStackedPhotoMessage(for: message)], conversationId: conversationId, action: .unpin)
SendMessageService.shared.sendPinMessages(items: [message], conversationId: conversationId, action: .unpin)
}
}

Expand Down Expand Up @@ -2677,13 +2670,9 @@ extension ConversationViewController {
guard let weakSelf = self, let indexPath = weakSelf.dataSource.indexPath(where: { $0.messageId == message.messageId }) else {
return
}
if message.category == MessageCategory.STACKED_PHOTO.rawValue {
message.messageItems?.forEach({ MessageDAO.shared.deleteMessage(id: $0.messageId) })
} else {
let (deleted, childMessageIds) = MessageDAO.shared.deleteMessage(id: message.messageId)
if deleted {
ReceiveMessageService.shared.stopRecallMessage(item: message, childMessageIds: childMessageIds)
}
let (deleted, childMessageIds) = MessageDAO.shared.deleteMessage(id: message.messageId)
if deleted {
ReceiveMessageService.shared.stopRecallMessage(item: message, childMessageIds: childMessageIds)
}
DispatchQueue.main.sync {
_ = weakSelf.dataSource?.removeViewModel(at: indexPath)
Expand Down Expand Up @@ -2728,16 +2717,15 @@ extension ConversationViewController {
let flashingId = self.messageIdToFlashAfterAnimationFinished
self.messageIdToFlashAfterAnimationFinished = nil
scroll(messageId, {
let msgId = self.messageIdIfIncluedInStackedPhotoMessage(for: messageId)
guard let indexPath = self.dataSource?.indexPath(where: { $0.messageId == msgId }) else {
guard let indexPath = self.dataSource?.indexPath(where: { $0.messageId == messageId }) else {
return
}
if scrollUpwards {
self.tableView.scrollToRow(at: indexPath, at: .bottom, animated: false)
} else {
self.tableView.scrollToRow(at: indexPath, at: .top, animated: false)
}
self.messageIdToFlashAfterAnimationFinished = flashingId != nil ? msgId : flashingId
self.messageIdToFlashAfterAnimationFinished = flashingId
self.tableView.scrollToRow(at: indexPath, at: .middle, animated: true)
})
}
Expand Down Expand Up @@ -2797,9 +2785,8 @@ extension ConversationViewController {
}

private func scrollToPinnedMessage(messageId: String) {
let msgId = messageIdIfIncluedInStackedPhotoMessage(for: messageId)
if let indexPath = dataSource.indexPath(where: { $0.messageId == msgId }) {
scheduleCellBackgroundFlash(messageId: msgId)
if let indexPath = dataSource.indexPath(where: { $0.messageId == messageId }) {
scheduleCellBackgroundFlash(messageId: messageId)
tableView.scrollToRow(at: indexPath, at: .middle, animated: true)
} else if MessageDAO.shared.hasMessage(id: messageId) {
messageIdToFlashAfterAnimationFinished = messageId
Expand All @@ -2815,30 +2802,6 @@ extension ConversationViewController {
}
}

private func messageIdIfIncluedInStackedPhotoMessage(for messageId: String) -> String {
guard !dataSource.stackedPhotoMessages.isEmpty else {
return messageId
}
let msgId: String
let stackedPhotoMessage = dataSource.stackedPhotoMessages.first { message in
message.messageItems?.contains(where: { $0.messageId == messageId }) ?? false
}
if let stackedPhotoMessageId = stackedPhotoMessage?.messageId {
msgId = stackedPhotoMessageId
} else {
msgId = messageId
}
return msgId
}

private func messageIfIncludedInStackedPhotoMessage(for message: MessageItem) -> MessageItem {
if message.category == MessageCategory.STACKED_PHOTO.rawValue, let photoMessage = message.messageItems?.first {
return photoMessage
} else {
return message
}
}

}

// MARK: - Context menu configs
Expand Down Expand Up @@ -2889,9 +2852,6 @@ extension ConversationViewController {
} else if let viewModel = viewModel as? AppButtonGroupViewModel {
param.visiblePath = UIBezierPath(roundedRect: viewModel.buttonGroupFrame,
cornerRadius: AppButtonView.cornerRadius)
} else if let viewModel = viewModel as? StackedPhotoMessageViewModel {
param.visiblePath = UIBezierPath(roundedRect: viewModel.stackedPhotoViewFrame,
cornerRadius: 13)
} else {
if viewModel.style.contains(.received) {
if viewModel.style.contains(.tail) {
Expand Down
Loading

0 comments on commit efb5fe2

Please sign in to comment.