mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
always put typing indicator last
This commit is contained in:
parent
668cc22af3
commit
0ae4821950
|
@ -1166,23 +1166,23 @@ static const int kYapDatabaseRangeMinLength = 0;
|
||||||
[self ensureConversationProfileState];
|
[self ensureConversationProfileState];
|
||||||
|
|
||||||
__block BOOL hasError = NO;
|
__block BOOL hasError = NO;
|
||||||
|
id<ConversationViewItem> (^tryToAddViewItem)(TSInteraction *, YapDatabaseReadTransaction *) = ^(TSInteraction *interaction, YapDatabaseReadTransaction *transaction) {
|
||||||
|
OWSAssertDebug(interaction.uniqueId.length > 0);
|
||||||
|
|
||||||
|
id<ConversationViewItem> _Nullable viewItem = self.viewItemCache[interaction.uniqueId];
|
||||||
|
if (!viewItem) {
|
||||||
|
viewItem = [[ConversationInteractionViewItem alloc] initWithInteraction:interaction
|
||||||
|
isGroupThread:isGroupThread
|
||||||
|
transaction:transaction
|
||||||
|
conversationStyle:conversationStyle];
|
||||||
|
}
|
||||||
|
[viewItems addObject:viewItem];
|
||||||
|
OWSAssertDebug(!viewItemCache[interaction.uniqueId]);
|
||||||
|
viewItemCache[interaction.uniqueId] = viewItem;
|
||||||
|
return viewItem;
|
||||||
|
};
|
||||||
|
|
||||||
[self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
|
[self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
|
||||||
id<ConversationViewItem> (^tryToAddViewItem)(TSInteraction *) = ^(TSInteraction *interaction) {
|
|
||||||
OWSAssertDebug(interaction.uniqueId.length > 0);
|
|
||||||
|
|
||||||
id<ConversationViewItem> _Nullable viewItem = self.viewItemCache[interaction.uniqueId];
|
|
||||||
if (!viewItem) {
|
|
||||||
viewItem = [[ConversationInteractionViewItem alloc] initWithInteraction:interaction
|
|
||||||
isGroupThread:isGroupThread
|
|
||||||
transaction:transaction
|
|
||||||
conversationStyle:conversationStyle];
|
|
||||||
}
|
|
||||||
[viewItems addObject:viewItem];
|
|
||||||
OWSAssertDebug(!viewItemCache[interaction.uniqueId]);
|
|
||||||
viewItemCache[interaction.uniqueId] = viewItem;
|
|
||||||
return viewItem;
|
|
||||||
};
|
|
||||||
|
|
||||||
NSMutableArray<TSInteraction *> *interactions = [NSMutableArray new];
|
NSMutableArray<TSInteraction *> *interactions = [NSMutableArray new];
|
||||||
NSMutableSet<NSString *> *interactionIds = [NSMutableSet new];
|
NSMutableSet<NSString *> *interactionIds = [NSMutableSet new];
|
||||||
|
|
||||||
|
@ -1217,7 +1217,7 @@ static const int kYapDatabaseRangeMinLength = 0;
|
||||||
loadedInteractions:interactions
|
loadedInteractions:interactions
|
||||||
canLoadMoreItems:canLoadMoreItems];
|
canLoadMoreItems:canLoadMoreItems];
|
||||||
if (offers && [interactionIds containsObject:offers.beforeInteractionId]) {
|
if (offers && [interactionIds containsObject:offers.beforeInteractionId]) {
|
||||||
id<ConversationViewItem> offersItem = tryToAddViewItem(offers);
|
id<ConversationViewItem> offersItem = tryToAddViewItem(offers, transaction);
|
||||||
if ([offersItem.interaction isKindOfClass:[OWSContactOffersInteraction class]]) {
|
if ([offersItem.interaction isKindOfClass:[OWSContactOffersInteraction class]]) {
|
||||||
OWSContactOffersInteraction *oldOffers = (OWSContactOffersInteraction *)offersItem.interaction;
|
OWSContactOffersInteraction *oldOffers = (OWSContactOffersInteraction *)offersItem.interaction;
|
||||||
BOOL didChange = (oldOffers.hasBlockOffer != offers.hasBlockOffer
|
BOOL didChange = (oldOffers.hasBlockOffer != offers.hasBlockOffer
|
||||||
|
@ -1232,17 +1232,7 @@ static const int kYapDatabaseRangeMinLength = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (TSInteraction *interaction in interactions) {
|
for (TSInteraction *interaction in interactions) {
|
||||||
tryToAddViewItem(interaction);
|
tryToAddViewItem(interaction, transaction);
|
||||||
}
|
|
||||||
|
|
||||||
if (self.typingIndicatorsSender) {
|
|
||||||
id<ConversationViewItem> _Nullable lastViewItem = viewItems.lastObject;
|
|
||||||
uint64_t typingIndicatorTimestamp = (lastViewItem ? lastViewItem.interaction.timestamp + 1 : 1);
|
|
||||||
TSInteraction *interaction =
|
|
||||||
[[OWSTypingIndicatorInteraction alloc] initWithThread:self.thread
|
|
||||||
timestamp:typingIndicatorTimestamp
|
|
||||||
recipientId:self.typingIndicatorsSender];
|
|
||||||
tryToAddViewItem(interaction);
|
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
@ -1252,6 +1242,18 @@ static const int kYapDatabaseRangeMinLength = 0;
|
||||||
return [left.interaction compareForSorting:right.interaction];
|
return [left.interaction compareForSorting:right.interaction];
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
if (self.typingIndicatorsSender) {
|
||||||
|
[self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
|
||||||
|
id<ConversationViewItem> _Nullable lastViewItem = viewItems.lastObject;
|
||||||
|
uint64_t typingIndicatorTimestamp = (lastViewItem ? lastViewItem.interaction.timestamp + 1 : 1);
|
||||||
|
TSInteraction *interaction =
|
||||||
|
[[OWSTypingIndicatorInteraction alloc] initWithThread:self.thread
|
||||||
|
timestamp:typingIndicatorTimestamp
|
||||||
|
recipientId:self.typingIndicatorsSender];
|
||||||
|
tryToAddViewItem(interaction, transaction);
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
// Flag to ensure that we only increment once per launch.
|
// Flag to ensure that we only increment once per launch.
|
||||||
if (hasError) {
|
if (hasError) {
|
||||||
OWSLogWarn(@"incrementing version of: %@", TSMessageDatabaseViewExtensionName);
|
OWSLogWarn(@"incrementing version of: %@", TSMessageDatabaseViewExtensionName);
|
||||||
|
|
Loading…
Reference in a new issue