change: setUnread locally
This commit is contained in:
parent
ef854b3b4c
commit
783f734713
|
|
@ -435,12 +435,25 @@ class Room {
|
||||||
/// Returns true if this room is unread
|
/// Returns true if this room is unread
|
||||||
bool get isUnread => notificationCount > 0 || markedUnread;
|
bool get isUnread => notificationCount > 0 || markedUnread;
|
||||||
|
|
||||||
|
/// Sets an unread flag manually for this room. Similar to the setUnreadMarker
|
||||||
|
/// this changes the local account data model before syncing it to make sure
|
||||||
|
/// this works if there is no connection to the homeserver.
|
||||||
Future<void> setUnread(bool unread) async {
|
Future<void> setUnread(bool unread) async {
|
||||||
|
final content = MarkedUnread(unread).toJson();
|
||||||
|
await _handleFakeSync(SyncUpdate()
|
||||||
|
..rooms = (RoomsUpdate()
|
||||||
|
..join = (({}..[id] = (JoinedRoomUpdate()
|
||||||
|
..accountData = [
|
||||||
|
BasicRoomEvent()
|
||||||
|
..content = content
|
||||||
|
..roomId = id
|
||||||
|
..type = EventType.MarkedUnread
|
||||||
|
])))));
|
||||||
await client.setRoomAccountData(
|
await client.setRoomAccountData(
|
||||||
client.userID,
|
client.userID,
|
||||||
id,
|
id,
|
||||||
EventType.MarkedUnread,
|
EventType.MarkedUnread,
|
||||||
MarkedUnread(unread).toJson(),
|
content,
|
||||||
);
|
);
|
||||||
if (unread == false && lastEvent != null) {
|
if (unread == false && lastEvent != null) {
|
||||||
await sendReadMarker(
|
await sendReadMarker(
|
||||||
|
|
@ -918,14 +931,12 @@ class Room {
|
||||||
await client.handleSync(
|
await client.handleSync(
|
||||||
SyncUpdate()
|
SyncUpdate()
|
||||||
..rooms = (RoomsUpdate()
|
..rooms = (RoomsUpdate()
|
||||||
..join = {
|
..join = ({}..[id] = (JoinedRoomUpdate()
|
||||||
'$id': (JoinedRoomUpdate()
|
..state = resp.state
|
||||||
..state = resp.state
|
..timeline = (TimelineUpdate()
|
||||||
..timeline = (TimelineUpdate()
|
..limited = false
|
||||||
..limited = false
|
..events = resp.chunk
|
||||||
..events = resp.chunk
|
..prevBatch = resp.end)))),
|
||||||
..prevBatch = resp.end)),
|
|
||||||
}),
|
|
||||||
sortAtTheEnd: true);
|
sortAtTheEnd: true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue