From bf8ccf1426291250aec4bf9de92a41bbb55e3193 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=BCller?= Date: Sun, 22 Sep 2024 13:58:36 +0200 Subject: [PATCH] Don't require a room object to render messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcel Müller --- NextcloudTalk/BaseChatTableViewCell.swift | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/NextcloudTalk/BaseChatTableViewCell.swift b/NextcloudTalk/BaseChatTableViewCell.swift index 7b839484..05efa923 100644 --- a/NextcloudTalk/BaseChatTableViewCell.swift +++ b/NextcloudTalk/BaseChatTableViewCell.swift @@ -167,15 +167,16 @@ class BaseChatTableViewCell: UITableViewCell, ReactionsViewDelegate { self.titleLabel.attributedText = titleLabel let activeAccount = NCDatabaseManager.sharedInstance().activeAccount() + var shouldShowDeliveryStatus = false + var shouldShowReadStatus = false - guard let room = NCDatabaseManager.sharedInstance().room(withToken: message.token, forAccountId: activeAccount.accountId) - else { return } + if let room = NCDatabaseManager.sharedInstance().room(withToken: message.token, forAccountId: activeAccount.accountId) { + shouldShowDeliveryStatus = NCDatabaseManager.sharedInstance().roomHasTalkCapability(kCapabilityChatReadStatus, for: room) - let shouldShowDeliveryStatus = NCDatabaseManager.sharedInstance().roomHasTalkCapability(kCapabilityChatReadStatus, for: room) - - // In case we are not able to retrieve the capabilities of the room, we fall back to readPrivacy = true -> hiding the read status - let roomCapabilities = NCDatabaseManager.sharedInstance().roomTalkCapabilities(for: room) - let shouldShowReadStatus = !(roomCapabilities?.readStatusPrivacy ?? true) + if let roomCapabilities = NCDatabaseManager.sharedInstance().roomTalkCapabilities(for: room) { + shouldShowReadStatus = !(roomCapabilities.readStatusPrivacy) + } + } // This check is just a workaround to fix the issue with the deleted parents returned by the API. if let parent = message.parent {