Fix Event decode bug

This commit is contained in:
Christian Pauly 2019-07-03 11:19:45 +02:00
parent 8aa27feac3
commit 9666b763a5
2 changed files with 3 additions and 6 deletions

View file

@ -130,12 +130,11 @@ class Event {
static Event fromJson(Map<String, dynamic> jsonObj, Room room) { static Event fromJson(Map<String, dynamic> jsonObj, Room room) {
Map<String, dynamic> content = jsonObj["content"]; Map<String, dynamic> content = jsonObj["content"];
if (content == null) if (content == null && jsonObj["content_json"] != null)
try { try {
content = json.decode(jsonObj["content_json"]); content = json.decode(jsonObj["content_json"]);
} catch (e) { } catch (e) {
print( print("jsonObj decode of event content failed: ${e.toString()}");
"jsonObj decode of event content '$jsonObj' failed: ${e.toString()}");
content = {}; content = {};
} }

View file

@ -474,10 +474,8 @@ class Store {
List<Event> eventList = []; List<Event> eventList = [];
for (num i = 0; i < eventRes.length; i++) { for (num i = 0; i < eventRes.length; i++)
print("Try to parse Event $i of ${eventRes.length}: ${eventRes[i]}");
eventList.add(Event.fromJson(eventRes[i], room)); eventList.add(Event.fromJson(eventRes[i], room));
}
return eventList; return eventList;
} }