fix(ffi): add Pop and Clear to VecDiff for sliding-sync

This commit is contained in:
Benjamin Kampmann
2023-01-11 17:29:24 +01:00
parent 3c6c5f4fae
commit 51f2e773a0
2 changed files with 6 additions and 4 deletions

View File

@@ -82,9 +82,8 @@ interface SlidingSyncViewRoomsListDiff {
u32 new_index
);
Push(RoomListEntry value);
// The following are supported by the generic VecDiff-type but
// in sliding sync effectively do not happen and thus aren't exposed
// to not pollute the API: Pop(); Clear();
Pop();
Clear();
};
callback interface SlidingSyncViewRoomListObserver {

View File

@@ -216,6 +216,8 @@ pub enum SlidingSyncViewRoomsListDiff {
RemoveAt { index: u32 },
Move { old_index: u32, new_index: u32 },
Push { value: RoomListEntry },
Pop, // removes the last item
Clear, // clears the list
}
impl From<VecDiff<MatrixRoomEntry>> for SlidingSyncViewRoomsListDiff {
@@ -242,7 +244,8 @@ impl From<VecDiff<MatrixRoomEntry>> for SlidingSyncViewRoomsListDiff {
VecDiff::Push { value } => {
SlidingSyncViewRoomsListDiff::Push { value: (&value).into() }
}
_ => unimplemented!("Clear and Pop aren't provided within sliding sync"),
VecDiff::Pop {} => SlidingSyncViewRoomsListDiff::Pop,
VecDiff::Clear {} => SlidingSyncViewRoomsListDiff::Clear,
}
}
}