From cbb6627849e500c47b0e70ed6014d5cfab957acb Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Fri, 7 Feb 2025 18:32:10 +0100 Subject: [PATCH] make isMarkerOrInfo reusable from other places --- deltachat-ios/Chat/ChatViewController.swift | 10 +++------- deltachat-ios/DC/DcMsg.swift | 4 ++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/deltachat-ios/Chat/ChatViewController.swift b/deltachat-ios/Chat/ChatViewController.swift index 1c53ba968..b9749fdf1 100644 --- a/deltachat-ios/Chat/ChatViewController.swift +++ b/deltachat-ios/Chat/ChatViewController.swift @@ -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 @@ -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) diff --git a/deltachat-ios/DC/DcMsg.swift b/deltachat-ios/DC/DcMsg.swift index c8f96655e..ae38f69d0 100644 --- a/deltachat-ios/DC/DcMsg.swift +++ b/deltachat-ios/DC/DcMsg.swift @@ -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)) }