Fix Event decode bug
This commit is contained in:
parent
8aa27feac3
commit
9666b763a5
|
@ -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 = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue