Skip to content

Commit

Permalink
make isMarkerOrInfo reusable from other places
Browse files Browse the repository at this point in the history
  • Loading branch information
r10s committed Feb 7, 2025
1 parent 331f9e0 commit cbb6627
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 3 additions & 7 deletions deltachat-ios/Chat/ChatViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -957,16 +957,12 @@ class ChatViewController: UITableViewController, UITableViewDropDelegate {
self.reloadData()
}

private func isMarkerOrInfo(_ message: DcMsg) -> Bool {
return message.id == DC_MSG_ID_MARKER1 || message.id == DC_MSG_ID_DAYMARKER || message.isInfo || message.type == DC_MSG_VIDEOCHAT_INVITATION
}

private func canReply(to message: DcMsg) -> Bool {
return !isMarkerOrInfo(message) && dcChat.canSend
return !message.isMarkerOrInfo && dcChat.canSend
}

private func canReplyPrivately(to message: DcMsg) -> Bool {
return !isMarkerOrInfo(message) && dcChat.isGroup && !message.isFromCurrentSender
return !message.isMarkerOrInfo && dcChat.isGroup && !message.isFromCurrentSender
}

/// Verifies if the last message cell is fully visible
Expand Down Expand Up @@ -1921,7 +1917,7 @@ extension ChatViewController {
UIAction.menuAction(localizationKey: "forward", systemImageName: "arrowshape.turn.up.forward", indexPath: indexPath, action: forward)
)

if !dcChat.isSelfTalk && !isMarkerOrInfo(message) { // info-messages out of context are confusing, see #2567
if !dcChat.isSelfTalk && !message.isMarkerOrInfo { // info-messages out of context are confusing, see #2567
if message.savedMessageId != 0 {
children.append(
UIAction.menuAction(localizationKey: "unsave", systemImageName: "bookmark.slash", indexPath: indexPath, action: toggleSave)
Expand Down
4 changes: 4 additions & 0 deletions deltachat-ios/DC/DcMsg.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ public class DcMsg {
return Int(dc_msg_get_from_id(messagePointer))
}

public var isMarkerOrInfo: Bool {
return id == DC_MSG_ID_MARKER1 || id == DC_MSG_ID_DAYMARKER || isInfo || type == DC_MSG_VIDEOCHAT_INVITATION
}

public var originalMessageId: Int {
return Int(dc_msg_get_original_msg_id(messagePointer))
}
Expand Down

0 comments on commit cbb6627

Please sign in to comment.