Merge branch 'room-fix-requesthistoryquery' into 'master'
[Room] Fix the requestHistory query. See merge request famedly/famedlysdk!25
This commit is contained in:
commit
a05068d156
|
@ -106,7 +106,7 @@ class Room {
|
|||
this.avatar,
|
||||
this.notificationCount,
|
||||
this.highlightCount,
|
||||
this.prev_batch,
|
||||
this.prev_batch = "",
|
||||
this.draft,
|
||||
this.unread,
|
||||
this.fullyRead,
|
||||
|
@ -295,8 +295,8 @@ class Room {
|
|||
Future<void> requestHistory({int historyCount = 100}) async {
|
||||
final dynamic resp = await client.connection.jsonRequest(
|
||||
type: "GET",
|
||||
action: "/client/r0/rooms/$id/messages",
|
||||
data: {"from": prev_batch, "dir": "b", "limit": historyCount});
|
||||
action:
|
||||
"/client/r0/rooms/$id/messages?from=${prev_batch}&dir=b&limit=$historyCount");
|
||||
|
||||
if (resp is ErrorResponse) return;
|
||||
|
||||
|
|
|
@ -31,8 +31,11 @@ class FakeMatrixApi extends MockClient {
|
|||
FakeMatrixApi()
|
||||
: super((request) async {
|
||||
// Collect data from Request
|
||||
final String action = request.url.path.split("/_matrix")[1];
|
||||
String action =
|
||||
request.url.path.split("/_matrix")[1] + "?" + request.url.query;
|
||||
if (action.endsWith("?")) action = action.replaceAll("?", "");
|
||||
final String method = request.method;
|
||||
print("Got action: $action");
|
||||
final dynamic data =
|
||||
method == "GET" ? request.url.queryParameters : request.body;
|
||||
var res = {};
|
||||
|
@ -76,7 +79,8 @@ class FakeMatrixApi extends MockClient {
|
|||
"origin_server_ts": 1432735824653,
|
||||
"unsigned": {"age": 1234}
|
||||
},
|
||||
"/client/r0/rooms/!1234:example.com/messages": (var req) => {
|
||||
"/client/r0/rooms/!1234:example.com/messages?from=1234&dir=b&limit=100":
|
||||
(var req) => {
|
||||
"start": "t47429-4392820_219380_26003_2265",
|
||||
"end": "t47409-4357353_219380_26003_2265",
|
||||
"chunk": [
|
||||
|
@ -306,7 +310,8 @@ class FakeMatrixApi extends MockClient {
|
|||
]
|
||||
}
|
||||
},
|
||||
"/client/r0/sync": (var req) => {
|
||||
"/client/r0/sync?filters=%7B%22room%22:%7B%22include_leave%22:true,%22state%22:%7B%22lazy_load_members%22:1%7D%7D":
|
||||
(var req) => {
|
||||
"next_batch": Random().nextDouble().toString(),
|
||||
"presence": {
|
||||
"events": [
|
||||
|
@ -371,7 +376,10 @@ class FakeMatrixApi extends MockClient {
|
|||
"sender": "@alice:example.com",
|
||||
"type": "m.room.message",
|
||||
"txn_id": "1234",
|
||||
"content": {"body": "I am a fish", "msgtype": "m.text"},
|
||||
"content": {
|
||||
"body": "I am a fish",
|
||||
"msgtype": "m.text"
|
||||
},
|
||||
"origin_server_ts": 1417731086797,
|
||||
"event_id": "74686972643033:example.com"
|
||||
}
|
||||
|
@ -401,7 +409,9 @@ class FakeMatrixApi extends MockClient {
|
|||
},
|
||||
{
|
||||
"type": "org.example.custom.room.config",
|
||||
"content": {"custom_config_key": "custom_config_value"}
|
||||
"content": {
|
||||
"custom_config_key": "custom_config_value"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ void main() {
|
|||
client.connection.httpClient = FakeMatrixApi();
|
||||
client.homeserver = "https://fakeServer.notExisting";
|
||||
|
||||
Room room = Room(id: roomID, client: client);
|
||||
Room room = Room(id: roomID, client: client, prev_batch: "1234");
|
||||
Timeline timeline = Timeline(
|
||||
room: room,
|
||||
events: [],
|
||||
|
|
Loading…
Reference in a new issue