Fix unfindable context on reshared posts in 2023.04 by looking at parentId as well

codemagic-setup
Hank Grabowski 2023-04-27 20:35:46 -04:00
rodzic d586ee3206
commit 1d63f7d0f0
1 zmienionych plików z 20 dodań i 1 usunięć

Wyświetl plik

@ -419,16 +419,35 @@ class EntryManagerService extends ChangeNotifier {
_logger.finest('Refreshing post: $id');
final client = StatusesClient(getIt<AccountsService>().currentProfile);
final idForCall = mapInteractionId(id);
var parentId = '';
final result = await client
.getPostOrComment(idForCall, fullContext: false)
.withResult((entries) =>
parentId = entries.isEmpty ? '' : entries.first.parentId ?? '')
.andThenAsync((rootItems) async => await client
.getPostOrComment(idForCall, fullContext: true)
.andThenSuccessAsync(
(contextItems) async => [...rootItems, ...contextItems]))
.andThenSuccessAsync((items) async {
.withResult((items) async {
await processNewItems(items, client.profile.username, null);
});
if (parentId.isNotEmpty &&
getIt<FriendicaVersionChecker>()
.canUseFeature(RelaticaFeatures.reshareIdFix)) {
final parentIdForCall = mapInteractionId(parentId);
await client
.getPostOrComment(parentIdForCall, fullContext: false)
.withResult((entries) =>
parentId = entries.isEmpty ? '' : entries.first.parentId ?? '')
.andThenAsync((rootItems) async => await client
.getPostOrComment(idForCall, fullContext: true)
.transformAsync(
(contextItems) async => [...rootItems, ...contextItems]))
.withResult((items) async {
await processNewItems(items, client.profile.username, null);
});
}
return result.mapValue((_) {
_logger.finest('$id post updated');
return _nodeToTreeItem(_getPostRootNode(id)!, client.profile.userId);