ThreadItemSet.newFromAnnotatedNodes needs to wait to compute names

Computing the name, for headings, requires determining the oldest
comment. This must not be done before all the replies are added to the
thread.

Follow-up to e24550fae9. It was
already *technically* incorrect before then because it was generating
the name based on the first comment in the thread, but that was only
not the oldest in very unusual cases so it was fine. That commit caused
the thread summary to be cached when first requested, however, which
made future requests for oldest/newest comment and authors to be
incorrect.

Bug: T318057
Change-Id: If0bd6caf88e72cd3f91e7f0633c40b445f5e2246
This commit is contained in:
David Lynch 2022-09-19 14:11:34 -05:00
parent 82f107af7e
commit 9ee2301f1e

View file

@ -60,13 +60,13 @@ ThreadItemSet.static.newFromAnnotatedNodes = function ( nodes, rootNode, parser
itemsById[ id ].parent = item;
return itemsById[ id ];
} );
// Calculate names (currently not stored in the metadata)
item.name = parser.computeName( item );
result.updateIdAndNameMaps( item );
}
// Calculate names (currently not stored in the metadata) - can't be done
// in the above loop because we have to wait until we have all the
// replies.
parser.computeIdsAndNames( result );
return result;
};