Merge branch 'client-refactor-remove-lazyloadingcheck' into 'master'
[Client] Remove lazyloadingcheck See merge request famedly/famedlysdk!257
This commit is contained in:
commit
31871235a5
|
@ -113,10 +113,6 @@ class Client {
|
||||||
List<String> get matrixVersions => _matrixVersions;
|
List<String> get matrixVersions => _matrixVersions;
|
||||||
List<String> _matrixVersions;
|
List<String> _matrixVersions;
|
||||||
|
|
||||||
/// Wheither the server supports lazy load members.
|
|
||||||
bool get lazyLoadMembers => _lazyLoadMembers;
|
|
||||||
bool _lazyLoadMembers = false;
|
|
||||||
|
|
||||||
/// Returns the current login state.
|
/// Returns the current login state.
|
||||||
bool isLogged() => accessToken != null;
|
bool isLogged() => accessToken != null;
|
||||||
|
|
||||||
|
@ -210,7 +206,7 @@ class Client {
|
||||||
|
|
||||||
/// Checks the supported versions of the Matrix protocol and the supported
|
/// Checks the supported versions of the Matrix protocol and the supported
|
||||||
/// login types. Returns false if the server is not compatible with the
|
/// login types. Returns false if the server is not compatible with the
|
||||||
/// client. Automatically sets [matrixVersions] and [lazyLoadMembers].
|
/// client. Automatically sets [matrixVersions].
|
||||||
/// Throws FormatException, TimeoutException and MatrixException on error.
|
/// Throws FormatException, TimeoutException and MatrixException on error.
|
||||||
Future<bool> checkServer(serverUrl) async {
|
Future<bool> checkServer(serverUrl) async {
|
||||||
try {
|
try {
|
||||||
|
@ -230,14 +226,6 @@ class Client {
|
||||||
|
|
||||||
_matrixVersions = versions;
|
_matrixVersions = versions;
|
||||||
|
|
||||||
if (versionResp.containsKey('unstable_features') &&
|
|
||||||
versionResp['unstable_features'].containsKey('m.lazy_load_members')) {
|
|
||||||
_lazyLoadMembers = versionResp['unstable_features']
|
|
||||||
['m.lazy_load_members']
|
|
||||||
? true
|
|
||||||
: false;
|
|
||||||
}
|
|
||||||
|
|
||||||
final loginResp =
|
final loginResp =
|
||||||
await jsonRequest(type: HTTPType.GET, action: '/client/r0/login');
|
await jsonRequest(type: HTTPType.GET, action: '/client/r0/login');
|
||||||
|
|
||||||
|
@ -303,8 +291,7 @@ class Client {
|
||||||
newHomeserver: homeserver,
|
newHomeserver: homeserver,
|
||||||
newDeviceName: initialDeviceDisplayName ?? '',
|
newDeviceName: initialDeviceDisplayName ?? '',
|
||||||
newDeviceID: response['device_id'],
|
newDeviceID: response['device_id'],
|
||||||
newMatrixVersions: matrixVersions,
|
newMatrixVersions: matrixVersions);
|
||||||
newLazyLoadMembers: lazyLoadMembers);
|
|
||||||
}
|
}
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
@ -346,7 +333,6 @@ class Client {
|
||||||
newDeviceName: initialDeviceDisplayName ?? '',
|
newDeviceName: initialDeviceDisplayName ?? '',
|
||||||
newDeviceID: loginResp['device_id'],
|
newDeviceID: loginResp['device_id'],
|
||||||
newMatrixVersions: matrixVersions,
|
newMatrixVersions: matrixVersions,
|
||||||
newLazyLoadMembers: lazyLoadMembers,
|
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -676,7 +662,6 @@ class Client {
|
||||||
String newDeviceName,
|
String newDeviceName,
|
||||||
String newDeviceID,
|
String newDeviceID,
|
||||||
List<String> newMatrixVersions,
|
List<String> newMatrixVersions,
|
||||||
bool newLazyLoadMembers,
|
|
||||||
String newPrevBatch,
|
String newPrevBatch,
|
||||||
String newOlmAccount,
|
String newOlmAccount,
|
||||||
}) async {
|
}) async {
|
||||||
|
@ -686,7 +671,6 @@ class Client {
|
||||||
_deviceID = newDeviceID;
|
_deviceID = newDeviceID;
|
||||||
_deviceName = newDeviceName;
|
_deviceName = newDeviceName;
|
||||||
_matrixVersions = newMatrixVersions;
|
_matrixVersions = newMatrixVersions;
|
||||||
_lazyLoadMembers = newLazyLoadMembers;
|
|
||||||
prevBatch = newPrevBatch;
|
prevBatch = newPrevBatch;
|
||||||
|
|
||||||
// Try to create a new olm account or restore a previous one.
|
// Try to create a new olm account or restore a previous one.
|
||||||
|
@ -762,8 +746,8 @@ class Client {
|
||||||
});
|
});
|
||||||
_olmAccount?.free();
|
_olmAccount?.free();
|
||||||
storeAPI?.clear();
|
storeAPI?.clear();
|
||||||
_accessToken = _homeserver = _userID = _deviceID =
|
_accessToken = _homeserver =
|
||||||
_deviceName = _matrixVersions = _lazyLoadMembers = prevBatch = null;
|
_userID = _deviceID = _deviceName = _matrixVersions = prevBatch = null;
|
||||||
onLoginStateChanged.add(LoginState.loggedOut);
|
onLoginStateChanged.add(LoginState.loggedOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,6 @@ void main() {
|
||||||
newDeviceName: 'Text Matrix Client',
|
newDeviceName: 'Text Matrix Client',
|
||||||
newDeviceID: resp['device_id'],
|
newDeviceID: resp['device_id'],
|
||||||
newMatrixVersions: matrix.matrixVersions,
|
newMatrixVersions: matrix.matrixVersions,
|
||||||
newLazyLoadMembers: matrix.lazyLoadMembers,
|
|
||||||
newOlmAccount: pickledOlmAccount,
|
newOlmAccount: pickledOlmAccount,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -281,7 +280,6 @@ void main() {
|
||||||
expect(matrix.deviceID == null, true);
|
expect(matrix.deviceID == null, true);
|
||||||
expect(matrix.deviceName == null, true);
|
expect(matrix.deviceName == null, true);
|
||||||
expect(matrix.matrixVersions == null, true);
|
expect(matrix.matrixVersions == null, true);
|
||||||
expect(matrix.lazyLoadMembers == null, true);
|
|
||||||
expect(matrix.prevBatch == null, true);
|
expect(matrix.prevBatch == null, true);
|
||||||
|
|
||||||
var loginState = await loginStateFuture;
|
var loginState = await loginStateFuture;
|
||||||
|
@ -654,7 +652,6 @@ void main() {
|
||||||
'r0.4.0',
|
'r0.4.0',
|
||||||
'r0.5.0'
|
'r0.5.0'
|
||||||
],
|
],
|
||||||
newLazyLoadMembers: true,
|
|
||||||
newOlmAccount: pickledOlmAccount,
|
newOlmAccount: pickledOlmAccount,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -683,7 +680,6 @@ void main() {
|
||||||
expect(client2.deviceID, client1.deviceID);
|
expect(client2.deviceID, client1.deviceID);
|
||||||
expect(client2.deviceName, client1.deviceName);
|
expect(client2.deviceName, client1.deviceName);
|
||||||
expect(client2.matrixVersions, client1.matrixVersions);
|
expect(client2.matrixVersions, client1.matrixVersions);
|
||||||
expect(client2.lazyLoadMembers, client1.lazyLoadMembers);
|
|
||||||
if (client2.encryptionEnabled) {
|
if (client2.encryptionEnabled) {
|
||||||
expect(client2.pickledOlmAccount, client1.pickledOlmAccount);
|
expect(client2.pickledOlmAccount, client1.pickledOlmAccount);
|
||||||
expect(json.encode(client2.rooms[1].sessionKeys[sessionKey]),
|
expect(json.encode(client2.rooms[1].sessionKeys[sessionKey]),
|
||||||
|
|
|
@ -31,7 +31,6 @@ class FakeStore implements StoreAPI {
|
||||||
newDeviceID: credentials['deviceID'],
|
newDeviceID: credentials['deviceID'],
|
||||||
newDeviceName: credentials['deviceName'],
|
newDeviceName: credentials['deviceName'],
|
||||||
newHomeserver: credentials['homeserver'],
|
newHomeserver: credentials['homeserver'],
|
||||||
newLazyLoadMembers: credentials['lazyLoadMembers'],
|
|
||||||
newMatrixVersions: List<String>.from(credentials['matrixVersions']),
|
newMatrixVersions: List<String>.from(credentials['matrixVersions']),
|
||||||
newToken: credentials['token'],
|
newToken: credentials['token'],
|
||||||
newUserID: credentials['userID'],
|
newUserID: credentials['userID'],
|
||||||
|
@ -47,7 +46,6 @@ class FakeStore implements StoreAPI {
|
||||||
'deviceID': client.deviceID,
|
'deviceID': client.deviceID,
|
||||||
'deviceName': client.deviceName,
|
'deviceName': client.deviceName,
|
||||||
'homeserver': client.homeserver,
|
'homeserver': client.homeserver,
|
||||||
'lazyLoadMembers': client.lazyLoadMembers,
|
|
||||||
'matrixVersions': client.matrixVersions,
|
'matrixVersions': client.matrixVersions,
|
||||||
'token': client.accessToken,
|
'token': client.accessToken,
|
||||||
'userID': client.userID,
|
'userID': client.userID,
|
||||||
|
|
Loading…
Reference in a new issue