-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: type safety in Matrix Dart SDK database #1679
fix: type safety in Matrix Dart SDK database #1679
Conversation
- removes unsafe casts - builds list using List<T>.from constructor - removes unwanted late statement Signed-off-by: The one with the braid <[email protected]>
Fixes: krille-chan/fluffychat#794 |
@@ -433,7 +434,7 @@ class MatrixSdkDatabase extends DatabaseApi { | |||
? timelineEventIds.getRange(start, end).toList() | |||
: []); | |||
|
|||
return await _getEventsByIds(eventIds.cast<String>(), room); | |||
return await _getEventsByIds(eventIds, room); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has already been fixed here: 2afd704
List<Map<String, dynamic>>.from( | ||
childEntries.whereType<Map<String, dynamic>>()), | ||
List<Map<String, dynamic>>.from( | ||
crossSigningEntries.whereType<Map<String, dynamic>>()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
List<T>.from()
is not better than list.cast<T>()
as it crashes in the same way when there is an entry which is not T
. The difference is that List<T>.from()
create a non-deep copy. Do we need this here? Also this is unrelated to the bug described in the commit message
@@ -1489,7 +1486,7 @@ class MatrixSdkDatabase extends DatabaseApi { | |||
try { | |||
await clear(); | |||
await open(); | |||
final json = Map.from(jsonDecode(export)).cast<String, Map>(); | |||
final json = Map<String, Map>.from(jsonDecode(export)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here. This does not prevent type errors or makes anything more type safe. It just creates a non-deep copy
Seems to be outdated now. Please ping me if I see this wrong |
Got the following premium bug report sent via matrix :