Merge branch 'roomlist-enhance-add-copywith' into 'master'

Add copyWith method to RoomList

See merge request famedly/famedlysdk!112
This commit is contained in:
Marcel 2019-10-28 14:59:10 +00:00
commit 166bc9e48d

View file

@ -75,6 +75,24 @@ class RoomList {
sort();
}
RoomList copyWith({
Client client,
List<Room> rooms,
onRoomListUpdateCallback onUpdate,
onRoomListInsertCallback onInsert,
onRoomListRemoveCallback onRemove,
bool onlyLeft,
}) {
return RoomList(
client: client ?? this.client,
rooms: rooms ?? this.rooms,
onUpdate: onUpdate ?? this.onUpdate,
onInsert: onInsert ?? this.onInsert,
onRemove: onRemove ?? this.onRemove,
onlyLeft: onlyLeft ?? this.onlyLeft,
);
}
Room getRoomByAlias(String alias) {
for (int i = 0; i < rooms.length; i++) {
if (rooms[i].canonicalAlias == alias) return rooms[i];