Skip to content
Snippets Groups Projects
Commit cd9397f2 authored by Kateryna Kostiuk's avatar Kateryna Kostiuk
Browse files

conversation: fix message sequensing

Ensure that item is not typing indicator when computing
message.

Change-Id: I6fbcddfd7006d2a6bd18f1aeda1be15413b46b90
parent 38a77e34
No related branches found
No related tags found
No related merge requests found
......@@ -793,6 +793,9 @@ typedef NS_ENUM(NSInteger, MessageSequencing) {
}
-(MessageSequencing) computeSequencingFor:(NSInteger) row {
if (row >= conversationView.numberOfRows - 1) {
return SINGLE_WITHOUT_TIME;
}
auto* conv = [self getCurrentConversation];
if (conv == nil)
return SINGLE_WITHOUT_TIME;
......@@ -805,20 +808,24 @@ typedef NS_ENUM(NSInteger, MessageSequencing) {
if (interaction.type != lrc::api::interaction::Type::TEXT) {
return SINGLE_WITH_TIME;
}
// first message in comversation
if (row == 0) {
if (it == conv->interactions.end()) {
return SINGLE_WITH_TIME;
}
auto nextIt = it;
nextIt++;
if (nextIt == conv->interactions.end()) {
return SINGLE_WITH_TIME;
}
auto nextInteraction = nextIt->second;
if ([self sequenceChangedFrom:interaction to: nextInteraction]) {
return SINGLE_WITH_TIME;
}
return FIRST_WITH_TIME;
}
if (row == conversationView.numberOfRows - 1) {
// last message in comversation
if (row == conversationView.numberOfRows - 2) {
if(it == conv->interactions.begin()) {
return SINGLE_WITH_TIME;
}
......@@ -835,14 +842,19 @@ typedef NS_ENUM(NSInteger, MessageSequencing) {
}
return SINGLE_WITH_TIME;
}
// single message in comversation
if(it == conv->interactions.begin() || it == conv->interactions.end()) {
return SINGLE_WITH_TIME;
}
// message in the middle of conversation
auto previousIt = it;
previousIt--;
auto previousInteraction = previousIt->second;
auto nextIt = it;
nextIt++;
if (nextIt == conv->interactions.end()) {
return SINGLE_WITHOUT_TIME;
}
auto nextInteraction = nextIt->second;
bool timeChanged = [self sequenceTimeChangedFrom:interaction to:previousInteraction];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment