feat: get fully read marker

This commit is contained in:
Henri Carnot 2022-05-02 08:43:54 +00:00
parent 951db4c8d7
commit f23abcd323
2 changed files with 14 additions and 0 deletions

View File

@ -1220,6 +1220,15 @@ class Room {
return;
}
/// Get the user fully read marker
String? get userFullyReadMarker {
final readEvent = roomAccountData['m.fully_read'];
if (readEvent != null) {
return readEvent.content.tryGet<String>('event_id');
}
return null;
}
/// Sets the position of the read marker for a given room, and optionally the
/// read receipt's location.
Future<void> setReadMarker(String eventId, {String? mRead}) async {

View File

@ -70,6 +70,10 @@ void main() {
type: 'com.test.foo',
content: {'foo': 'bar'},
),
'm.fully_read': BasicRoomEvent(
type: 'm.fully_read',
content: {'event_id': '\$event_id:example.com'},
),
},
);
room.setState(Event(
@ -94,6 +98,7 @@ void main() {
expect(
room.getState('m.room.join_rules')?.content['join_rule'], 'public');
expect(room.roomAccountData['com.test.foo']?.content['foo'], 'bar');
expect(room.userFullyReadMarker, '\$event_id:example.com');
room.setState(
Event(