Merge branch 'room-fix-sender-not-being-loaded' into 'master'
[Room]/[Store] Load sender user when loading event by id See merge request famedly/famedlysdk!56
This commit is contained in:
commit
237e8640b4
|
@ -493,6 +493,19 @@ class Room {
|
||||||
return participants;
|
return participants;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<User> getUserByMXID(String mxID) async {
|
||||||
|
if (client.store != null) {
|
||||||
|
final User storeEvent =
|
||||||
|
await client.store.getUser(matrixID: mxID, room: this);
|
||||||
|
if (storeEvent != null) return storeEvent;
|
||||||
|
}
|
||||||
|
final dynamic resp = await client.connection.jsonRequest(
|
||||||
|
type: HTTPType.GET,
|
||||||
|
action: "/client/r0/rooms/$id/state/m.room.member/$mxID");
|
||||||
|
if (resp is ErrorResponse) return null;
|
||||||
|
return User.fromJson(resp, this);
|
||||||
|
}
|
||||||
|
|
||||||
/// Searches for the event in the store. If it isn't found, try to request it
|
/// Searches for the event in the store. If it isn't found, try to request it
|
||||||
/// from the server. Returns null if not found.
|
/// from the server. Returns null if not found.
|
||||||
Future<Event> getEventById(String eventID) async {
|
Future<Event> getEventById(String eventID) async {
|
||||||
|
@ -503,6 +516,7 @@ class Room {
|
||||||
final dynamic resp = await client.connection.jsonRequest(
|
final dynamic resp = await client.connection.jsonRequest(
|
||||||
type: HTTPType.GET, action: "/client/r0/rooms/$id/event/$eventID");
|
type: HTTPType.GET, action: "/client/r0/rooms/$id/event/$eventID");
|
||||||
if (resp is ErrorResponse) return null;
|
if (resp is ErrorResponse) return null;
|
||||||
return Event.fromJson(resp, this);
|
return Event.fromJson(resp, this,
|
||||||
|
senderUser: (await getUserByMXID(resp["sender"])));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -650,7 +650,8 @@ class Store {
|
||||||
List<Map<String, dynamic>> res = await db.rawQuery(
|
List<Map<String, dynamic>> res = await db.rawQuery(
|
||||||
"SELECT * FROM Events WHERE id=? AND chat_id=?", [eventID, room.id]);
|
"SELECT * FROM Events WHERE id=? AND chat_id=?", [eventID, room.id]);
|
||||||
if (res.length == 0) return null;
|
if (res.length == 0) return null;
|
||||||
return Event.fromJson(res[0], room);
|
return Event.fromJson(res[0], room,
|
||||||
|
senderUser: (await room.getUserByMXID(res[0]["sender"])));
|
||||||
}
|
}
|
||||||
|
|
||||||
Future forgetNotification(String roomID) async {
|
Future forgetNotification(String roomID) async {
|
||||||
|
|
Loading…
Reference in a new issue