diff --git a/lib/src/model/basic_event_with_sender.dart b/lib/src/model/basic_event_with_sender.dart index 6c93fd07..6c90e8c9 100644 --- a/lib/src/model/basic_event_with_sender.dart +++ b/lib/src/model/basic_event_with_sender.dart @@ -28,10 +28,8 @@ class BasicEventWithSender extends BasicEvent { BasicEventWithSender(); - BasicEventWithSender.fromJson(Map json) { - final basicEvent = BasicEvent.fromJson(json); - type = basicEvent.type; - content = basicEvent.content; + BasicEventWithSender.fromJson(Map json) + : super.fromJson(json) { senderId = json['sender']; } diff --git a/lib/src/model/basic_room_event.dart b/lib/src/model/basic_room_event.dart index 8a97ee72..27f28e8f 100644 --- a/lib/src/model/basic_room_event.dart +++ b/lib/src/model/basic_room_event.dart @@ -35,10 +35,7 @@ class BasicRoomEvent extends BasicEvent { type: type, ); - BasicRoomEvent.fromJson(Map json) { - final basicEvent = BasicEvent.fromJson(json); - content = basicEvent.content; - type = basicEvent.type; + BasicRoomEvent.fromJson(Map json) : super.fromJson(json) { roomId = json['room_id']; } diff --git a/lib/src/model/filter.dart b/lib/src/model/filter.dart index 7103ec1e..391537cf 100644 --- a/lib/src/model/filter.dart +++ b/lib/src/model/filter.dart @@ -190,14 +190,7 @@ class StateFilter extends EventFilter { notSenders: notSenders, ); - StateFilter.fromJson(Map json) { - final eventFilter = EventFilter.fromJson(json); - limit = eventFilter.limit; - senders = eventFilter.senders; - types = eventFilter.types; - notRooms = eventFilter.notRooms; - notSenders = eventFilter.notSenders; - + StateFilter.fromJson(Map json) : super.fromJson(json) { notTypes = json['not_types']?.cast(); lazyLoadMembers = json['lazy_load_members']; includeRedundantMembers = json['include_redundant_members']; diff --git a/lib/src/model/matrix_event.dart b/lib/src/model/matrix_event.dart index 74dd4296..705f2f04 100644 --- a/lib/src/model/matrix_event.dart +++ b/lib/src/model/matrix_event.dart @@ -34,12 +34,7 @@ class MatrixEvent extends StrippedStateEvent { MatrixEvent(); - MatrixEvent.fromJson(Map json) { - final strippedStateEvent = StrippedStateEvent.fromJson(json); - content = strippedStateEvent.content; - type = strippedStateEvent.type; - senderId = strippedStateEvent.senderId; - stateKey = strippedStateEvent.stateKey; + MatrixEvent.fromJson(Map json) : super.fromJson(json) { eventId = json['event_id']; roomId = json['room_id']; originServerTs = diff --git a/lib/src/model/presence.dart b/lib/src/model/presence.dart index 93d17c9b..7d9fb753 100644 --- a/lib/src/model/presence.dart +++ b/lib/src/model/presence.dart @@ -27,11 +27,7 @@ import 'presence_content.dart'; class Presence extends BasicEventWithSender { PresenceContent presence; - Presence.fromJson(Map json) { - final basicEvent = BasicEventWithSender.fromJson(json); - type = basicEvent.type; - content = basicEvent.content; - senderId = basicEvent.senderId; + Presence.fromJson(Map json) : super.fromJson(json) { presence = PresenceContent.fromJson(content); } } diff --git a/lib/src/model/stripped_state_event.dart b/lib/src/model/stripped_state_event.dart index da9298ff..e6d1edd5 100644 --- a/lib/src/model/stripped_state_event.dart +++ b/lib/src/model/stripped_state_event.dart @@ -27,11 +27,8 @@ class StrippedStateEvent extends BasicEventWithSender { String stateKey; StrippedStateEvent(); - StrippedStateEvent.fromJson(Map json) { - final basicEvent = BasicEventWithSender.fromJson(json); - content = basicEvent.content; - type = basicEvent.type; - senderId = basicEvent.senderId; + StrippedStateEvent.fromJson(Map json) + : super.fromJson(json) { stateKey = json['state_key']; }