From a4aee976ac42b355f3989b13ac83b8c6331e07b1 Mon Sep 17 00:00:00 2001 From: kkostiuk <kateryna.kostiuk@savoirfairelinux.com> Date: Fri, 8 Oct 2021 09:59:40 -0400 Subject: [PATCH] conversation: adapt to changes in messages model Change-Id: Iaad737ded6633664bc4ee07456a2640facee05cf --- src/ConversationVC.mm | 2 +- src/MessagesVC.mm | 14 +++++++------- src/SmartViewVC.mm | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/ConversationVC.mm b/src/ConversationVC.mm index a3838a4f..1200a6c5 100644 --- a/src/ConversationVC.mm +++ b/src/ConversationVC.mm @@ -287,7 +287,7 @@ NSInteger const SEND_PANEL_MAX_HEIGHT = 120; - (void)updateInvitationView:(const lrc::api::conversation::Info*) conversation { self.isRequest = conversation->isRequest || conversation->needsSyncing; NSString* bestName = bestNameForConversation(*conversation, *convModel_); - bool showInvitationView = conversation->isRequest || (convModel_->owner.profileInfo.type == lrc::api::profile::Type::JAMI && conversation->interactions.size() == 0); + bool showInvitationView = conversation->isRequest || (convModel_->owner.profileInfo.type == lrc::api::profile::Type::JAMI && conversation->interactions->size() == 0); invitationView.hidden = !showInvitationView; invitationBlock.enabled = !conversation->needsSyncing && conversation->isRequest; invitationRefuse.enabled = !conversation->needsSyncing && conversation->isRequest; diff --git a/src/MessagesVC.mm b/src/MessagesVC.mm index 97023709..0921941e 100644 --- a/src/MessagesVC.mm +++ b/src/MessagesVC.mm @@ -442,7 +442,7 @@ typedef NS_ENUM(NSInteger, MessageSequencing) { -(void)reloadMessages { auto* conv = [self getCurrentConversation]; messages = {}; - for (auto& interaction : conv->interactions) { + for (auto& interaction : *conv->interactions) { bool transferForOtherDevice = interaction.second.type == lrc::api::interaction::Type::DATA_TRANSFER && interaction.second.body.isEmpty() && lrc::api::interaction::isOutgoing(interaction.second); if (interaction.second.type != lrc::api::interaction::Type::MERGE && !transferForOtherDevice) { messages.push_back(std::make_pair(interaction.first, interaction.second)); @@ -650,8 +650,8 @@ typedef NS_ENUM(NSInteger, MessageSequencing) { } -(NSString*) getFilePath:(const QString&) interId { - auto it = [self getCurrentConversation]->interactions.find(interId); - if (it == [self getCurrentConversation]->interactions.end()) { + auto it = [self getCurrentConversation]->interactions->find(interId); + if (it == [self getCurrentConversation]->interactions->end()) { return @""; } auto& interaction = it->second; @@ -699,12 +699,12 @@ typedef NS_ENUM(NSInteger, MessageSequencing) { - (void)deleteMessage:(id)sender { auto interId = QString::fromNSString([sender representedObject]); auto conv = [self getCurrentConversation]; - auto it = conv->interactions.find(interId); - if (it == conv->interactions.end()) { + auto it = conv->interactions->find(interId); + if (it == conv->interactions->end()) { return; } - auto itIndex = std::distance(conv->interactions.begin(),it); - if (itIndex >= ([conversationView numberOfRows] - 1) || itIndex >= conv->interactions.size()) { + auto itIndex = std::distance(conv->interactions->begin(),it); + if (itIndex >= ([conversationView numberOfRows] - 1) || itIndex >= conv->interactions->size()) { return; } NSIndexSet* indexSet = [NSIndexSet indexSetWithIndex: itIndex]; diff --git a/src/SmartViewVC.mm b/src/SmartViewVC.mm index 9ae51499..e75c9514 100755 --- a/src/SmartViewVC.mm +++ b/src/SmartViewVC.mm @@ -573,9 +573,9 @@ NSInteger const REQUEST_SEG = 1; [interactionSnippet setHidden:true]; return result; } - if (conversation.interactions.find(lastUid) != conversation.interactions.end()) { + if (conversation.interactions->find(lastUid) != conversation.interactions->end()) { // last interaction snippet - auto lastInteractionSnippet = conversation.interactions[lastUid].body.trimmed().replace("\r","").replace("\n",""); + auto lastInteractionSnippet = (*conversation.interactions)[lastUid].body.trimmed().replace("\r","").replace("\n",""); NSString* lastInteractionSnippetFixedString = [lastInteractionSnippet.toNSString() stringByReplacingOccurrencesOfString:@"🕽" withString:@""]; lastInteractionSnippetFixedString = [lastInteractionSnippetFixedString stringByReplacingOccurrencesOfString:@"📞" withString:@""]; @@ -583,7 +583,7 @@ NSInteger const REQUEST_SEG = 1; // last interaction date/time NSString *timeString = @""; - NSDate* msgTime = [NSDate dateWithTimeIntervalSince1970:conversation.interactions[lastUid].timestamp]; + NSDate* msgTime = [NSDate dateWithTimeIntervalSince1970:(*conversation.interactions)[lastUid].timestamp]; NSDate *today = [NSDate date]; NSDateFormatter *dateFormatter=[[NSDateFormatter alloc] init]; [dateFormatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:[[NSLocale currentLocale] localeIdentifier]]]; -- GitLab