mirror of
https://github.com/immich-app/immich.git
synced 2026-05-18 03:10:24 +03:00
fix(mobile): reset asset index on timeline refresh (#25729)
The current asset changes when the timeline refreshes, which can be quite jarring. Assets are tracked by their index, and that index becomes stale when the timeline refreshes. This can be resolved by updating the index of asset based on a unique identifier (like the hero tag).
This commit is contained in:
@@ -227,6 +227,13 @@ class TimelineService {
|
||||
return _buffer.elementAt(index - _bufferOffset);
|
||||
}
|
||||
|
||||
/// Finds the index of an asset by its heroTag within the current buffer.
|
||||
/// Returns null if the asset is not found in the buffer.
|
||||
int? getIndex(String heroTag) {
|
||||
final index = _buffer.indexWhere((a) => a.heroTag == heroTag);
|
||||
return index >= 0 ? _bufferOffset + index : null;
|
||||
}
|
||||
|
||||
Future<void> dispose() async {
|
||||
await _bucketSubscription?.cancel();
|
||||
_bucketSubscription = null;
|
||||
|
||||
Reference in New Issue
Block a user