Merge pull request #1935 from famedly/krille/migrate-to-spec-mark-unread

refactor: Migrate to m.marked_unread from Matrix v1.12
This commit is contained in:
Krille-chan 2024-10-08 15:10:30 +02:00 committed by GitHub
commit 9973a81bde
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 8 additions and 6 deletions

View File

@ -2597,7 +2597,7 @@ class FakeMatrixApi extends BaseClient {
(var req) => {},
'/client/v3/user/%40alice%3Aexample.com/rooms/1234/account_data/test.account.data':
(var req) => {},
'/client/v3/user/%40test%3AfakeServer.notExisting/rooms/!localpart%3Aserver.abc/account_data/com.famedly.marked_unread':
'/client/v3/user/%40test%3AfakeServer.notExisting/rooms/!localpart%3Aserver.abc/account_data/m.marked_unread':
(var req) => {},
'/client/v3/user/%40test%3AfakeServer.notExisting/account_data/m.direct':
(var req) => {},

View File

@ -493,7 +493,9 @@ class Room {
bool get markedUnread {
return MarkedUnread.fromJson(
roomAccountData[EventType.markedUnread]?.content ?? {})
roomAccountData[EventType.markedUnread]?.content ??
roomAccountData[EventType.oldMarkedUnread]?.content ??
{})
.unread;
}

View File

@ -19,7 +19,8 @@
import 'package:matrix/matrix_api_lite.dart';
mixin EventType {
static const String markedUnread = 'com.famedly.marked_unread';
static const String markedUnread = 'm.marked_unread';
static const String oldMarkedUnread = 'com.famedly.marked_unread';
}
class MarkedUnread {

View File

@ -1226,10 +1226,9 @@ void main() {
await room.markUnread(true);
await room.markUnread(false);
expect(room.markedUnread, false);
room.roomAccountData['com.famedly.marked_unread'] =
BasicRoomEvent.fromJson({
room.roomAccountData['m.marked_unread'] = BasicRoomEvent.fromJson({
'content': {'unread': true},
'type': 'com.famedly.marked_unread'
'type': 'm.marked_unread'
});
expect(room.markedUnread, true);
});