refactor: Make via fields not nullable
This commit is contained in:
parent
96fd74497b
commit
849bd7ca9b
|
|
@ -516,8 +516,8 @@ class FamedlySdkHiveDatabase extends DatabaseApi with ZoneTransactionMixin {
|
|||
Future<List<OlmSession>> getOlmSessions(
|
||||
String identityKey, String userId) async {
|
||||
final rawSessions =
|
||||
await _olmSessionsBox.get(identityKey.toHiveKey) as Map?;
|
||||
if (rawSessions == null || rawSessions.isEmpty) return <OlmSession>[];
|
||||
await _olmSessionsBox.get(identityKey.toHiveKey) as Map? ?? {};
|
||||
|
||||
return rawSessions.values
|
||||
.map((json) => OlmSession.fromJson(convertToJson(json), userId))
|
||||
.toList();
|
||||
|
|
|
|||
|
|
@ -2233,7 +2233,7 @@ class Room {
|
|||
states[EventTypes.spaceParent]
|
||||
?.values
|
||||
.map((state) => SpaceParent.fromState(state))
|
||||
.where((child) => child.via?.isNotEmpty ?? false)
|
||||
.where((child) => child.via.isNotEmpty)
|
||||
.toList() ??
|
||||
[];
|
||||
|
||||
|
|
@ -2246,7 +2246,7 @@ class Room {
|
|||
: (states[EventTypes.spaceChild]
|
||||
?.values
|
||||
.map((state) => SpaceChild.fromState(state))
|
||||
.where((child) => child.via?.isNotEmpty ?? false)
|
||||
.where((child) => child.via.isNotEmpty)
|
||||
.toList() ??
|
||||
[])
|
||||
..sort((a, b) => a.order.isEmpty || b.order.isEmpty
|
||||
|
|
|
|||
|
|
@ -21,26 +21,26 @@ import 'package:matrix/src/event.dart';
|
|||
|
||||
class SpaceChild {
|
||||
final String? roomId;
|
||||
final List<String>? via;
|
||||
final List<String> via;
|
||||
final String order;
|
||||
final bool? suggested;
|
||||
|
||||
SpaceChild.fromState(Event state)
|
||||
: assert(state.type == EventTypes.spaceChild),
|
||||
roomId = state.stateKey,
|
||||
via = state.content.tryGetList<String>('via'),
|
||||
via = state.content.tryGetList<String>('via') ?? [],
|
||||
order = state.content.tryGet<String>('order') ?? '',
|
||||
suggested = state.content.tryGet<bool>('suggested');
|
||||
}
|
||||
|
||||
class SpaceParent {
|
||||
final String? roomId;
|
||||
final List<String>? via;
|
||||
final List<String> via;
|
||||
final bool? canonical;
|
||||
|
||||
SpaceParent.fromState(Event state)
|
||||
: assert(state.type == EventTypes.spaceParent),
|
||||
roomId = state.stateKey,
|
||||
via = state.content.tryGetList<String>('via'),
|
||||
via = state.content.tryGetList<String>('via') ?? [],
|
||||
canonical = state.content.tryGet<bool>('canonical');
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue