mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-22 03:58:48 +00:00
Fix in-memory message updates.
We can also switch to using the message-specific update route for receipts too.
This commit is contained in:
@@ -195,13 +195,24 @@ class FixedSizePagingController<Key, Data> implements PagingController<Key> {
|
||||
List<Data> updatedList = new CompressedList<>(data);
|
||||
|
||||
updatedList.add(position, item);
|
||||
keyToPosition.put(dataSource.getKey(item), position);
|
||||
rebuildKeyToPositionMap(keyToPosition, updatedList, dataSource);
|
||||
|
||||
data = updatedList;
|
||||
liveData.postValue(updatedList);
|
||||
});
|
||||
}
|
||||
|
||||
private void rebuildKeyToPositionMap(@NonNull Map<Key, Integer> map, @NonNull List<Data> dataList, @NonNull PagedDataSource<Key, Data> dataSource) {
|
||||
map.clear();
|
||||
|
||||
for (int i = 0, len = dataList.size(); i < len; i++) {
|
||||
Data item = dataList.get(i);
|
||||
if (item != null) {
|
||||
map.put(dataSource.getKey(item), i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String buildLog(int aroundIndex, String message) {
|
||||
return "onDataNeededAroundIndex(" + aroundIndex + ") " + message;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user