[Room] Fix the requestHistory query.
This commit is contained in:
parent
3f72cf2c05
commit
c56c2f0a95
|
@ -106,7 +106,7 @@ class Room {
|
||||||
this.avatar,
|
this.avatar,
|
||||||
this.notificationCount,
|
this.notificationCount,
|
||||||
this.highlightCount,
|
this.highlightCount,
|
||||||
this.prev_batch,
|
this.prev_batch = "",
|
||||||
this.draft,
|
this.draft,
|
||||||
this.unread,
|
this.unread,
|
||||||
this.fullyRead,
|
this.fullyRead,
|
||||||
|
@ -295,8 +295,8 @@ class Room {
|
||||||
Future<void> requestHistory({int historyCount = 100}) async {
|
Future<void> requestHistory({int historyCount = 100}) async {
|
||||||
final dynamic resp = await client.connection.jsonRequest(
|
final dynamic resp = await client.connection.jsonRequest(
|
||||||
type: "GET",
|
type: "GET",
|
||||||
action: "/client/r0/rooms/$id/messages",
|
action:
|
||||||
data: {"from": prev_batch, "dir": "b", "limit": historyCount});
|
"/client/r0/rooms/$id/messages?from=${prev_batch}&dir=b&limit=$historyCount");
|
||||||
|
|
||||||
if (resp is ErrorResponse) return;
|
if (resp is ErrorResponse) return;
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,11 @@ class FakeMatrixApi extends MockClient {
|
||||||
FakeMatrixApi()
|
FakeMatrixApi()
|
||||||
: super((request) async {
|
: super((request) async {
|
||||||
// Collect data from Request
|
// 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;
|
final String method = request.method;
|
||||||
|
print("Got action: $action");
|
||||||
final dynamic data =
|
final dynamic data =
|
||||||
method == "GET" ? request.url.queryParameters : request.body;
|
method == "GET" ? request.url.queryParameters : request.body;
|
||||||
var res = {};
|
var res = {};
|
||||||
|
@ -76,7 +79,8 @@ class FakeMatrixApi extends MockClient {
|
||||||
"origin_server_ts": 1432735824653,
|
"origin_server_ts": 1432735824653,
|
||||||
"unsigned": {"age": 1234}
|
"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",
|
"start": "t47429-4392820_219380_26003_2265",
|
||||||
"end": "t47409-4357353_219380_26003_2265",
|
"end": "t47409-4357353_219380_26003_2265",
|
||||||
"chunk": [
|
"chunk": [
|
||||||
|
|
|
@ -41,7 +41,7 @@ void main() {
|
||||||
client.connection.httpClient = FakeMatrixApi();
|
client.connection.httpClient = FakeMatrixApi();
|
||||||
client.homeserver = "https://fakeServer.notExisting";
|
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(
|
Timeline timeline = Timeline(
|
||||||
room: room,
|
room: room,
|
||||||
events: [],
|
events: [],
|
||||||
|
|
Loading…
Reference in a new issue