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 {
// Get the synced event IDs from the store
final timelineKey = TupleKey(room.id, '').toString();
final timelineEventIds =
(await _timelineFragmentsBox.get(timelineKey) ?? []);
final timelineEventIds = List<String>.from(
(await _timelineFragmentsBox.get(timelineKey)) ?? []);
// Get the local stored SENDING events from the store
late final List<String> sendingEventIds;
@ -395,10 +395,8 @@ class HiveCollectionsDatabase extends DatabaseApi {
sendingEventIds = [];
} else {
final sendingTimelineKey = TupleKey(room.id, 'SENDING').toString();
sendingEventIds =
(await _timelineFragmentsBox.get(sendingTimelineKey) ?? [])
.whereType<String>()
.toList();
sendingEventIds = List<String>.from(
(await _timelineFragmentsBox.get(sendingTimelineKey)) ?? []);
}
// 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 {
// Get the synced event IDs from the store
final timelineKey = TupleKey(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
late final List<String> sendingEventIds;
@ -435,9 +432,8 @@ class HiveCollectionsDatabase extends DatabaseApi {
sendingEventIds = [];
} else {
final sendingTimelineKey = TupleKey(room.id, 'SENDING').toString();
sendingEventIds = (await _timelineFragmentsBox.get(sendingTimelineKey)
as List<String>? ??
[]);
sendingEventIds = List<String>.from(
(await _timelineFragmentsBox.get(sendingTimelineKey)) ?? []);
}
// 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 {
// Get the synced event IDs from the store
final timelineKey = MultiKey(room.id, '').toString();
final timelineEventIds =
(await _timelineFragmentsBox.get(timelineKey) as List? ?? []);
final timelineEventIds = List<String>.from(
(await _timelineFragmentsBox.get(timelineKey)) ?? []);
// Get the local stored SENDING events from the store
late final List sendingEventIds;
if (start != 0) {
sendingEventIds = [];
} else {
final sendingTimelineKey = MultiKey(room.id, 'SENDING').toString();
sendingEventIds =
(await _timelineFragmentsBox.get(sendingTimelineKey) as List? ??
[]);
sendingEventIds = List<String>.from(
(await _timelineFragmentsBox.get(sendingTimelineKey)) ?? []);
}
// 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 {
// Get the synced event IDs from the store
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
late final List<String> sendingEventIds;
@ -438,9 +436,8 @@ class FamedlySdkHiveDatabase extends DatabaseApi {
sendingEventIds = [];
} else {
final sendingTimelineKey = MultiKey(room.id, 'SENDING').toString();
sendingEventIds = (await _timelineFragmentsBox.get(sendingTimelineKey)
as List<String>? ??
[]);
sendingEventIds = List<String>.from(
(await _timelineFragmentsBox.get(sendingTimelineKey)) ?? []);
}
// Combine those two lists while respecting the start and limit parameters.