fix: casting of a List<dynamic> to List<String> in getEventList and getEventIdList

This commit is contained in:
td 2023-04-28 00:55:20 +05:30
parent aa24c0ce66
commit 1928f292b0
No known key found for this signature in database
GPG Key ID: F6D9E9BF14C7D103
2 changed files with 17 additions and 24 deletions

View File

@ -386,8 +386,8 @@ class HiveCollectionsDatabase extends DatabaseApi {
runBenchmarked<List<Event>>('Get event list', () async { runBenchmarked<List<Event>>('Get event list', () async {
// Get the synced event IDs from the store // Get the synced event IDs from the store
final timelineKey = TupleKey(room.id, '').toString(); final timelineKey = TupleKey(room.id, '').toString();
final timelineEventIds = final timelineEventIds = List<String>.from(
(await _timelineFragmentsBox.get(timelineKey) ?? []); (await _timelineFragmentsBox.get(timelineKey)) ?? []);
// Get the local stored SENDING events from the store // Get the local stored SENDING events from the store
late final List<String> sendingEventIds; late final List<String> sendingEventIds;
@ -395,10 +395,8 @@ class HiveCollectionsDatabase extends DatabaseApi {
sendingEventIds = []; sendingEventIds = [];
} else { } else {
final sendingTimelineKey = TupleKey(room.id, 'SENDING').toString(); final sendingTimelineKey = TupleKey(room.id, 'SENDING').toString();
sendingEventIds = sendingEventIds = List<String>.from(
(await _timelineFragmentsBox.get(sendingTimelineKey) ?? []) (await _timelineFragmentsBox.get(sendingTimelineKey)) ?? []);
.whereType<String>()
.toList();
} }
// Combine those two lists while respecting the start and limit parameters. // Combine those two lists while respecting the start and limit parameters.
@ -425,9 +423,8 @@ class HiveCollectionsDatabase extends DatabaseApi {
runBenchmarked<List<String>>('Get event id list', () async { runBenchmarked<List<String>>('Get event id list', () async {
// Get the synced event IDs from the store // Get the synced event IDs from the store
final timelineKey = TupleKey(room.id, '').toString(); final timelineKey = TupleKey(room.id, '').toString();
final timelineEventIds = final timelineEventIds = List<String>.from(
(await _timelineFragmentsBox.get(timelineKey) as List<String>? ?? (await _timelineFragmentsBox.get(timelineKey)) ?? []);
[]);
// Get the local stored SENDING events from the store // Get the local stored SENDING events from the store
late final List<String> sendingEventIds; late final List<String> sendingEventIds;
@ -435,9 +432,8 @@ class HiveCollectionsDatabase extends DatabaseApi {
sendingEventIds = []; sendingEventIds = [];
} else { } else {
final sendingTimelineKey = TupleKey(room.id, 'SENDING').toString(); final sendingTimelineKey = TupleKey(room.id, 'SENDING').toString();
sendingEventIds = (await _timelineFragmentsBox.get(sendingTimelineKey) sendingEventIds = List<String>.from(
as List<String>? ?? (await _timelineFragmentsBox.get(sendingTimelineKey)) ?? []);
[]);
} }
// Combine those two lists while respecting the start and limit parameters. // Combine those two lists while respecting the start and limit parameters.

View File

@ -393,18 +393,16 @@ class FamedlySdkHiveDatabase extends DatabaseApi {
runBenchmarked<List<Event>>('Get event list', () async { runBenchmarked<List<Event>>('Get event list', () async {
// Get the synced event IDs from the store // Get the synced event IDs from the store
final timelineKey = MultiKey(room.id, '').toString(); final timelineKey = MultiKey(room.id, '').toString();
final timelineEventIds = final timelineEventIds = List<String>.from(
(await _timelineFragmentsBox.get(timelineKey) as List? ?? []); (await _timelineFragmentsBox.get(timelineKey)) ?? []);
// Get the local stored SENDING events from the store // Get the local stored SENDING events from the store
late final List sendingEventIds; late final List sendingEventIds;
if (start != 0) { if (start != 0) {
sendingEventIds = []; sendingEventIds = [];
} else { } else {
final sendingTimelineKey = MultiKey(room.id, 'SENDING').toString(); final sendingTimelineKey = MultiKey(room.id, 'SENDING').toString();
sendingEventIds = sendingEventIds = List<String>.from(
(await _timelineFragmentsBox.get(sendingTimelineKey) as List? ?? (await _timelineFragmentsBox.get(sendingTimelineKey)) ?? []);
[]);
} }
// Combine those two lists while respecting the start and limit parameters. // Combine those two lists while respecting the start and limit parameters.
@ -428,9 +426,9 @@ class FamedlySdkHiveDatabase extends DatabaseApi {
runBenchmarked<List<String>>('Get event id list', () async { runBenchmarked<List<String>>('Get event id list', () async {
// Get the synced event IDs from the store // Get the synced event IDs from the store
final timelineKey = MultiKey(room.id, '').toString(); final timelineKey = MultiKey(room.id, '').toString();
final timelineEventIds =
(await _timelineFragmentsBox.get(timelineKey) as List<String>? ?? final timelineEventIds = List<String>.from(
[]); (await _timelineFragmentsBox.get(timelineKey)) ?? []);
// Get the local stored SENDING events from the store // Get the local stored SENDING events from the store
late final List<String> sendingEventIds; late final List<String> sendingEventIds;
@ -438,9 +436,8 @@ class FamedlySdkHiveDatabase extends DatabaseApi {
sendingEventIds = []; sendingEventIds = [];
} else { } else {
final sendingTimelineKey = MultiKey(room.id, 'SENDING').toString(); final sendingTimelineKey = MultiKey(room.id, 'SENDING').toString();
sendingEventIds = (await _timelineFragmentsBox.get(sendingTimelineKey) sendingEventIds = List<String>.from(
as List<String>? ?? (await _timelineFragmentsBox.get(sendingTimelineKey)) ?? []);
[]);
} }
// Combine those two lists while respecting the start and limit parameters. // Combine those two lists while respecting the start and limit parameters.