chore: use display event ID as token position cache key to prevent out-of-date positions being used to render edited messages (#2844)
This commit is contained in:
parent
e5e7f40220
commit
3adac7f63c
1 changed files with 7 additions and 3 deletions
|
|
@ -49,8 +49,12 @@ class MessageTextUtil {
|
|||
return null;
|
||||
}
|
||||
|
||||
if (_tokenPositionsCache.containsKey(pangeaMessageEvent.eventId)) {
|
||||
return _tokenPositionsCache[pangeaMessageEvent.eventId]!
|
||||
final cacheKey = pangeaMessageEvent.event
|
||||
.getDisplayEvent(pangeaMessageEvent.timeline)
|
||||
.eventId;
|
||||
|
||||
if (_tokenPositionsCache.containsKey(cacheKey)) {
|
||||
return _tokenPositionsCache[cacheKey]!
|
||||
.map(
|
||||
(t) => TokenPosition(
|
||||
start: t.start,
|
||||
|
|
@ -154,7 +158,7 @@ class MessageTextUtil {
|
|||
continue;
|
||||
}
|
||||
|
||||
_tokenPositionsCache[pangeaMessageEvent.eventId] = tokenPositions;
|
||||
_tokenPositionsCache[cacheKey] = tokenPositions;
|
||||
|
||||
return tokenPositions;
|
||||
} catch (err, s) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue