Fix: group color change doesn't immediately apply

Because we were fetching a new thread instance, instead of updating the
existing thread instance, classes which were bound to the old thread instance
weren't updating. This affected the HeaderView.AvatarView.thread and the
ConversationStyle.thread.
pull/1/head
Michael Kirk 7 years ago
parent 5fc21bce96
commit 006021ea41

@ -3239,17 +3239,7 @@ typedef enum : NSUInteger {
if (self.isGroupConversation) { if (self.isGroupConversation) {
[self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) { [self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
TSGroupThread *gThread = (TSGroupThread *)self.thread; [self.thread reloadWithTransaction:transaction];
if (gThread.groupModel) {
TSGroupThread *_Nullable updatedThread =
[TSGroupThread threadWithGroupId:gThread.groupModel.groupId transaction:transaction];
if (updatedThread) {
self.thread = updatedThread;
} else {
OWSFailDebug(@"Could not reload thread.");
}
}
}]; }];
[self updateNavigationTitle]; [self updateNavigationTitle];
} }

@ -94,6 +94,7 @@ NS_ASSUME_NONNULL_BEGIN
/** /**
* Assign the latest persisted values from the database. * Assign the latest persisted values from the database.
*/ */
- (void)reloadWithTransaction:(YapDatabaseReadTransaction *)transaction;
- (void)reload; - (void)reload;
/** /**

@ -220,7 +220,14 @@ NS_ASSUME_NONNULL_BEGIN
- (void)reload - (void)reload
{ {
TSYapDatabaseObject *latest = [[self class] fetchObjectWithUniqueID:self.uniqueId]; [self.dbReadConnection readWithBlock:^(YapDatabaseReadTransaction *_Nonnull transaction) {
[self reloadWithTransaction:transaction];
}];
}
- (void)reloadWithTransaction:(YapDatabaseReadTransaction *)transaction
{
TSYapDatabaseObject *latest = [[self class] fetchObjectWithUniqueID:self.uniqueId transaction:transaction];
if (!latest) { if (!latest) {
OWSFailDebug(@"`latest` was unexpectedly nil"); OWSFailDebug(@"`latest` was unexpectedly nil");
return; return;

Loading…
Cancel
Save