catch parsing errors for invalid replies
This commit is contained in:
parent
ae5b6e2b40
commit
83e8084213
1 changed files with 9 additions and 3 deletions
|
|
@ -17,6 +17,14 @@ abstract class Event with _$Event {
|
||||||
return content["m.new_content"] ?? content;
|
return content["m.new_content"] ?? content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static String? replyToFromJson(Map<dynamic, dynamic> json) {
|
||||||
|
try {
|
||||||
|
return json["m.relates_to"]?["m.in_reply_to"]?["event_id"];
|
||||||
|
} catch (_) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const factory Event({
|
const factory Event({
|
||||||
@JsonKey(name: "rowid") required int rowId,
|
@JsonKey(name: "rowid") required int rowId,
|
||||||
@JsonKey(name: "timeline_rowid") required int timelineRowId,
|
@JsonKey(name: "timeline_rowid") required int timelineRowId,
|
||||||
|
|
@ -45,9 +53,7 @@ abstract class Event with _$Event {
|
||||||
|
|
||||||
factory Event.fromJson(Map<String, dynamic> json) =>
|
factory Event.fromJson(Map<String, dynamic> json) =>
|
||||||
_$EventFromJson(json).copyWith(
|
_$EventFromJson(json).copyWith(
|
||||||
replyTo: getContentFromJson(
|
replyTo: replyToFromJson(getContentFromJson(json)),
|
||||||
json,
|
|
||||||
)["m.relates_to"]?["m.in_reply_to"]?["event_id"],
|
|
||||||
pmp: json["content"]?["com.beeper.per_message_profile"] == null
|
pmp: json["content"]?["com.beeper.per_message_profile"] == null
|
||||||
? null
|
? null
|
||||||
: Profile.fromJsonWithCatch(
|
: Profile.fromJsonWithCatch(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue