refactor: Change name of archive getter to function
This is more intuitive because it is a function that loads something from the server and doesnt directly return something.
This commit is contained in:
parent
cec08b3775
commit
2f35277e47
|
|
@ -276,7 +276,7 @@ class Client extends MatrixApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Searches in the local cache for the given room and returns null if not
|
/// Searches in the local cache for the given room and returns null if not
|
||||||
/// found. If you have loaded the [archive] before, it can also return
|
/// found. If you have loaded the [loadArchive()] before, it can also return
|
||||||
/// archived rooms.
|
/// archived rooms.
|
||||||
Room getRoomById(String id) {
|
Room getRoomById(String id) {
|
||||||
for (final room in <Room>[...rooms, ..._archivedRooms]) {
|
for (final room in <Room>[...rooms, ..._archivedRooms]) {
|
||||||
|
|
@ -651,7 +651,10 @@ class Client extends MatrixApi {
|
||||||
|
|
||||||
final List<Room> _archivedRooms = [];
|
final List<Room> _archivedRooms = [];
|
||||||
|
|
||||||
Future<List<Room>> get archive async {
|
@Deprecated('Use [loadArchive()] instead.')
|
||||||
|
Future<List<Room>> get archive => loadArchive();
|
||||||
|
|
||||||
|
Future<List<Room>> loadArchive() async {
|
||||||
_archivedRooms.clear();
|
_archivedRooms.clear();
|
||||||
final syncResp = await sync(
|
final syncResp = await sync(
|
||||||
filter: '{"room":{"include_leave":true,"timeline":{"limit":10}}}',
|
filter: '{"room":{"include_leave":true,"timeline":{"limit":10}}}',
|
||||||
|
|
|
||||||
|
|
@ -351,7 +351,7 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('get archive', () async {
|
test('get archive', () async {
|
||||||
final archive = await matrix.archive;
|
final archive = await matrix.loadArchive();
|
||||||
|
|
||||||
await Future.delayed(Duration(milliseconds: 50));
|
await Future.delayed(Duration(milliseconds: 50));
|
||||||
expect(archive.length, 2);
|
expect(archive.length, 2);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue