From 2b6fb87f7e86b41bd6e01b96e191ca6dec202d00 Mon Sep 17 00:00:00 2001 From: Giom Foret Date: Tue, 13 Nov 2018 17:30:37 +0100 Subject: [PATCH] Fix a race condition observed when the app renders an image in a Group/Community description --- .../Communities/Home/GroupHomeViewController.m | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Riot/Modules/Communities/Home/GroupHomeViewController.m b/Riot/Modules/Communities/Home/GroupHomeViewController.m index 8f2563729..247b49521 100644 --- a/Riot/Modules/Communities/Home/GroupHomeViewController.m +++ b/Riot/Modules/Communities/Home/GroupHomeViewController.m @@ -516,8 +516,6 @@ // Check whether the provided URL is a valid Matrix Content URI. if (cacheFilePath) { - localSourcePath = [NSString stringWithFormat:@"file://%@", cacheFilePath]; - // Download the thumbnail if it is not already stored in the cache. if (![[NSFileManager defaultManager] fileExistsAtPath:cacheFilePath]) { @@ -529,10 +527,15 @@ withMethod:MXThumbnailingMethodScale success:^(NSString *outputFilePath) { MXStrongifyAndReturnIfNil(self); - [self renderGroupLongDescription]; + [self refreshGroupLongDescription]; } failure:nil]; } + else + { + // Update the local path + localSourcePath = [NSString stringWithFormat:@"file://%@", cacheFilePath]; + } } } else @@ -545,8 +548,6 @@ // Check whether the provided URL is a valid Matrix Content URI. if (cacheFilePath) { - localSourcePath = [NSString stringWithFormat:@"file://%@", cacheFilePath]; - // Download the image if it is not already stored in the cache. if (![[NSFileManager defaultManager] fileExistsAtPath:cacheFilePath]) { @@ -556,10 +557,15 @@ inFolder:kMXMediaManagerDefaultCacheFolder success:^(NSString *outputFilePath) { MXStrongifyAndReturnIfNil(self); - [self renderGroupLongDescription]; + [self refreshGroupLongDescription]; } failure:nil]; } + else + { + // Update the local path + localSourcePath = [NSString stringWithFormat:@"file://%@", cacheFilePath]; + } } } return localSourcePath;