Merge branch 'krille/refactor-names' into 'main'

refactor: Rename methods and get rid of all Future getter

See merge request famedly/company/frontend/famedlysdk!1049
This commit is contained in:
Krille Fear 2022-06-08 08:05:23 +00:00
commit be8c3290a2
9 changed files with 71 additions and 57 deletions

View File

@ -91,7 +91,7 @@ class MatrixWidget {
// See https://github.com/matrix-org/matrix-doc/issues/1236 for a // See https://github.com/matrix-org/matrix-doc/issues/1236 for a
// description, specifically the section // description, specifically the section
// `What does the other stuff in content mean?` // `What does the other stuff in content mean?`
final userProfile = await room.client.ownProfile; final userProfile = await room.client.fetchOwnProfile();
var parsedUri = url; var parsedUri = url;
// a key-value map with the strings to be replaced // a key-value map with the strings to be replaced

View File

@ -707,11 +707,14 @@ class Client extends MatrixApi {
return id; return id;
} }
@Deprecated('Use fetchOwnProfile() instead')
Future<Profile> get ownProfile => fetchOwnProfile();
/// Returns the user's own displayname and avatar url. In Matrix it is possible that /// Returns the user's own displayname and avatar url. In Matrix it is possible that
/// one user can have different displaynames and avatar urls in different rooms. So /// one user can have different displaynames and avatar urls in different rooms. So
/// this endpoint first checks if the profile is the same in all rooms. If not, the /// this endpoint first checks if the profile is the same in all rooms. If not, the
/// profile will be requested from the homserver. /// profile will be requested from the homserver.
Future<Profile> get ownProfile async { Future<Profile> fetchOwnProfile() async {
if (rooms.isNotEmpty) { if (rooms.isNotEmpty) {
final profileSet = <Profile>{}; final profileSet = <Profile>{};
for (final room in rooms) { for (final room in rooms) {

View File

@ -37,8 +37,12 @@ abstract class RelationshipTypes {
/// All data exchanged over Matrix is expressed as an "event". Typically each client action (e.g. sending a message) correlates with exactly one event. /// All data exchanged over Matrix is expressed as an "event". Typically each client action (e.g. sending a message) correlates with exactly one event.
class Event extends MatrixEvent { class Event extends MatrixEvent {
Future<User?> get eventSender async => /// Requests the user object of the sender of this event.
await room.requestUser(senderId, ignoreErrors: true); Future<User?> fetchSenderUser() => room.requestUser(
senderId,
ignoreErrors: true,
);
@Deprecated( @Deprecated(
'Use eventSender instead or senderFromMemoryOrFallback for a synchronous alternative') 'Use eventSender instead or senderFromMemoryOrFallback for a synchronous alternative')
User get sender => senderFromMemoryOrFallback; User get sender => senderFromMemoryOrFallback;
@ -632,21 +636,21 @@ class Event extends MatrixEvent {
/// plaintextBody instead of the normal body. /// plaintextBody instead of the normal body.
/// [removeMarkdown] allow to remove the markdown formating from the event body. /// [removeMarkdown] allow to remove the markdown formating from the event body.
/// Usefull form message preview or notifications text. /// Usefull form message preview or notifications text.
Future<String> getLocalizedBodyAsync(MatrixLocalizations i18n, Future<String> calcLocalizedBody(MatrixLocalizations i18n,
{bool withSenderNamePrefix = false, {bool withSenderNamePrefix = false,
bool hideReply = false, bool hideReply = false,
bool hideEdit = false, bool hideEdit = false,
bool plaintextBody = false, bool plaintextBody = false,
bool removeMarkdown = false}) async { bool removeMarkdown = false}) async {
if (redacted) { if (redacted) {
await redactedBecause?.eventSender; await redactedBecause?.fetchSenderUser();
} }
if (withSenderNamePrefix && if (withSenderNamePrefix &&
(type == EventTypes.Message || type.contains(EventTypes.Encrypted))) { (type == EventTypes.Message || type.contains(EventTypes.Encrypted))) {
// To be sure that if the event need to be localized, the user is in memory. // To be sure that if the event need to be localized, the user is in memory.
// used by EventLocalizations._localizedBodyNormalMessage // used by EventLocalizations._localizedBodyNormalMessage
await eventSender; await fetchSenderUser();
} }
return _getLocalizedBody(i18n, return _getLocalizedBody(i18n,
@ -657,7 +661,7 @@ class Event extends MatrixEvent {
removeMarkdown: removeMarkdown); removeMarkdown: removeMarkdown);
} }
@Deprecated('Use getLocalizedBodyAsync') @Deprecated('Use calcLocalizedBody')
String getLocalizedBody(MatrixLocalizations i18n, String getLocalizedBody(MatrixLocalizations i18n,
{bool withSenderNamePrefix = false, {bool withSenderNamePrefix = false,
bool hideReply = false, bool hideReply = false,

View File

@ -525,9 +525,12 @@ class Room {
/// in muted rooms, use [hasNewMessages]. /// in muted rooms, use [hasNewMessages].
bool get isUnread => notificationCount > 0 || markedUnread; bool get isUnread => notificationCount > 0 || markedUnread;
@Deprecated('Use waitForRoomInSync() instead')
Future<SyncUpdate> get waitForSync => waitForRoomInSync();
/// Wait for the room to appear in join, leave or invited section of the /// Wait for the room to appear in join, leave or invited section of the
/// sync. /// sync.
Future<SyncUpdate> get waitForSync async { Future<SyncUpdate> waitForRoomInSync() async {
return await client.waitForRoomInSync(id); return await client.waitForRoomInSync(id);
} }

View File

@ -159,8 +159,11 @@ class User extends Event {
@Deprecated('Deprecated in favour of currentPresence.') @Deprecated('Deprecated in favour of currentPresence.')
Presence? get presence => room.client.presences[id]?.toPresence(); Presence? get presence => room.client.presences[id]?.toPresence();
@Deprecated('Use fetchCurrentPresence() instead')
Future<CachedPresence> get currentPresence => fetchCurrentPresence();
/// The newest presence of this user if there is any. Fetches it from the server if necessary or returns offline. /// The newest presence of this user if there is any. Fetches it from the server if necessary or returns offline.
Future<CachedPresence> get currentPresence async { Future<CachedPresence> fetchCurrentPresence() async {
final cachedPresence = room.client.presences[id]; final cachedPresence = room.client.presences[id];
if (cachedPresence != null) { if (cachedPresence != null) {
return cachedPresence; return cachedPresence;

View File

@ -1240,8 +1240,8 @@ class VoIP {
final newCall = createNewCall(opts); final newCall = createNewCall(opts);
newCall.remotePartyId = partyId; newCall.remotePartyId = partyId;
newCall.remoteUser = newCall.remoteUser = (await event.fetchSenderUser()) ??
(await event.eventSender) ?? User(event.senderId, room: event.room); User(event.senderId, room: event.room);
final offer = RTCSessionDescription( final offer = RTCSessionDescription(
event.content['offer']['sdp'], event.content['offer']['sdp'],
event.content['offer']['type'], event.content['offer']['type'],
@ -1285,8 +1285,8 @@ class VoIP {
} }
call.remotePartyId = partyId; call.remotePartyId = partyId;
call.remoteUser = call.remoteUser = await event.fetchSenderUser() ??
await event.eventSender ?? User(event.senderId, room: event.room); User(event.senderId, room: event.room);
final answer = RTCSessionDescription( final answer = RTCSessionDescription(
event.content['answer']['sdp'], event.content['answer']['type']); event.content['answer']['sdp'], event.content['answer']['type']);

File diff suppressed because one or more lines are too long

View File

@ -362,7 +362,7 @@ void main() {
} }
} }
}, room); }, room);
expect(await event.getLocalizedBodyAsync(MatrixDefaultLocalizations()), expect(await event.calcLocalizedBody(MatrixDefaultLocalizations()),
'Removed by Example'); 'Removed by Example');
expect(event.isEventTypeKnown, true); expect(event.isEventTypeKnown, true);
@ -429,7 +429,7 @@ void main() {
'type': 'm.sticker', 'type': 'm.sticker',
'unsigned': {'age': 1234} 'unsigned': {'age': 1234}
}, room); }, room);
expect(await event.getLocalizedBodyAsync(MatrixDefaultLocalizations()), expect(await event.calcLocalizedBody(MatrixDefaultLocalizations()),
'Example sent a sticker'); 'Example sent a sticker');
expect(event.isEventTypeKnown, true); expect(event.isEventTypeKnown, true);
@ -443,7 +443,7 @@ void main() {
'type': 'm.room.redaction', 'type': 'm.room.redaction',
'unsigned': {'age': 1234} 'unsigned': {'age': 1234}
}, room); }, room);
expect(await event.getLocalizedBodyAsync(MatrixDefaultLocalizations()), expect(await event.calcLocalizedBody(MatrixDefaultLocalizations()),
'Example redacted an event'); 'Example redacted an event');
expect(event.isEventTypeKnown, true); expect(event.isEventTypeKnown, true);
@ -459,7 +459,7 @@ void main() {
'type': 'm.room.aliases', 'type': 'm.room.aliases',
'unsigned': {'age': 1234} 'unsigned': {'age': 1234}
}, room); }, room);
expect(await event.getLocalizedBodyAsync(MatrixDefaultLocalizations()), expect(await event.calcLocalizedBody(MatrixDefaultLocalizations()),
'Example changed the room aliases'); 'Example changed the room aliases');
expect(event.isEventTypeKnown, true); expect(event.isEventTypeKnown, true);
@ -475,7 +475,7 @@ void main() {
'type': 'm.room.aliases', 'type': 'm.room.aliases',
'unsigned': {'age': 1234} 'unsigned': {'age': 1234}
}, room); }, room);
expect(await event.getLocalizedBodyAsync(MatrixDefaultLocalizations()), expect(await event.calcLocalizedBody(MatrixDefaultLocalizations()),
'Example changed the room aliases'); 'Example changed the room aliases');
expect(event.isEventTypeKnown, true); expect(event.isEventTypeKnown, true);
@ -489,7 +489,7 @@ void main() {
'type': 'm.room.canonical_alias', 'type': 'm.room.canonical_alias',
'unsigned': {'age': 1234} 'unsigned': {'age': 1234}
}, room); }, room);
expect(await event.getLocalizedBodyAsync(MatrixDefaultLocalizations()), expect(await event.calcLocalizedBody(MatrixDefaultLocalizations()),
'Example changed the room invitation link'); 'Example changed the room invitation link');
expect(event.isEventTypeKnown, true); expect(event.isEventTypeKnown, true);
@ -511,7 +511,7 @@ void main() {
'type': 'm.room.create', 'type': 'm.room.create',
'unsigned': {'age': 1234} 'unsigned': {'age': 1234}
}, room); }, room);
expect(await event.getLocalizedBodyAsync(MatrixDefaultLocalizations()), expect(await event.calcLocalizedBody(MatrixDefaultLocalizations()),
'Example created the chat'); 'Example created the chat');
expect(event.isEventTypeKnown, true); expect(event.isEventTypeKnown, true);
@ -528,7 +528,7 @@ void main() {
'type': 'm.room.tombstone', 'type': 'm.room.tombstone',
'unsigned': {'age': 1234} 'unsigned': {'age': 1234}
}, room); }, room);
expect(await event.getLocalizedBodyAsync(MatrixDefaultLocalizations()), expect(await event.calcLocalizedBody(MatrixDefaultLocalizations()),
'Room has been upgraded'); 'Room has been upgraded');
expect(event.isEventTypeKnown, true); expect(event.isEventTypeKnown, true);
@ -542,7 +542,7 @@ void main() {
'type': 'm.room.join_rules', 'type': 'm.room.join_rules',
'unsigned': {'age': 1234} 'unsigned': {'age': 1234}
}, room); }, room);
expect(await event.getLocalizedBodyAsync(MatrixDefaultLocalizations()), expect(await event.calcLocalizedBody(MatrixDefaultLocalizations()),
'Example changed the join rules to Anyone can join'); 'Example changed the join rules to Anyone can join');
expect(event.isEventTypeKnown, true); expect(event.isEventTypeKnown, true);
@ -560,7 +560,7 @@ void main() {
'type': 'm.room.member', 'type': 'm.room.member',
'unsigned': {'age': 1234} 'unsigned': {'age': 1234}
}, room); }, room);
expect(await event.getLocalizedBodyAsync(MatrixDefaultLocalizations()), expect(await event.calcLocalizedBody(MatrixDefaultLocalizations()),
'Alice joined the chat'); 'Alice joined the chat');
expect(event.isEventTypeKnown, true); expect(event.isEventTypeKnown, true);
@ -573,7 +573,7 @@ void main() {
'state_key': '@alice:example.org', 'state_key': '@alice:example.org',
'type': 'm.room.member' 'type': 'm.room.member'
}, room); }, room);
expect(await event.getLocalizedBodyAsync(MatrixDefaultLocalizations()), expect(await event.calcLocalizedBody(MatrixDefaultLocalizations()),
'Example has invited Alice'); 'Example has invited Alice');
expect(event.isEventTypeKnown, true); expect(event.isEventTypeKnown, true);
@ -589,7 +589,7 @@ void main() {
'prev_content': {'membership': 'join'}, 'prev_content': {'membership': 'join'},
} }
}, room); }, room);
expect(await event.getLocalizedBodyAsync(MatrixDefaultLocalizations()), expect(await event.calcLocalizedBody(MatrixDefaultLocalizations()),
'Example kicked Alice'); 'Example kicked Alice');
expect(event.isEventTypeKnown, true); expect(event.isEventTypeKnown, true);
@ -605,7 +605,7 @@ void main() {
'prev_content': {'membership': 'join'}, 'prev_content': {'membership': 'join'},
} }
}, room); }, room);
expect(await event.getLocalizedBodyAsync(MatrixDefaultLocalizations()), expect(await event.calcLocalizedBody(MatrixDefaultLocalizations()),
'Example banned Alice'); 'Example banned Alice');
expect(event.isEventTypeKnown, true); expect(event.isEventTypeKnown, true);
@ -621,7 +621,7 @@ void main() {
'prev_content': {'membership': 'invite'}, 'prev_content': {'membership': 'invite'},
} }
}, room); }, room);
expect(await event.getLocalizedBodyAsync(MatrixDefaultLocalizations()), expect(await event.calcLocalizedBody(MatrixDefaultLocalizations()),
'Alice accepted the invitation'); 'Alice accepted the invitation');
expect(event.isEventTypeKnown, true); expect(event.isEventTypeKnown, true);
@ -637,7 +637,7 @@ void main() {
'prev_content': {'membership': 'join'}, 'prev_content': {'membership': 'join'},
} }
}, room); }, room);
expect(await event.getLocalizedBodyAsync(MatrixDefaultLocalizations()), expect(await event.calcLocalizedBody(MatrixDefaultLocalizations()),
'Example has invited Alice'); 'Example has invited Alice');
expect(event.isEventTypeKnown, true); expect(event.isEventTypeKnown, true);
@ -653,7 +653,7 @@ void main() {
'prev_content': {'membership': 'invite'}, 'prev_content': {'membership': 'invite'},
} }
}, room); }, room);
expect(await event.getLocalizedBodyAsync(MatrixDefaultLocalizations()), expect(await event.calcLocalizedBody(MatrixDefaultLocalizations()),
'Example has withdrawn the invitation for Alice'); 'Example has withdrawn the invitation for Alice');
expect(event.isEventTypeKnown, true); expect(event.isEventTypeKnown, true);
@ -669,7 +669,7 @@ void main() {
'prev_content': {'membership': 'invite'}, 'prev_content': {'membership': 'invite'},
} }
}, room); }, room);
expect(await event.getLocalizedBodyAsync(MatrixDefaultLocalizations()), expect(await event.calcLocalizedBody(MatrixDefaultLocalizations()),
'Alice rejected the invitation'); 'Alice rejected the invitation');
expect(event.isEventTypeKnown, true); expect(event.isEventTypeKnown, true);
@ -694,7 +694,7 @@ void main() {
'type': 'm.room.power_levels', 'type': 'm.room.power_levels',
'unsigned': {'age': 1234} 'unsigned': {'age': 1234}
}, room); }, room);
expect(await event.getLocalizedBodyAsync(MatrixDefaultLocalizations()), expect(await event.calcLocalizedBody(MatrixDefaultLocalizations()),
'Example changed the chat permissions'); 'Example changed the chat permissions');
expect(event.isEventTypeKnown, true); expect(event.isEventTypeKnown, true);
@ -708,7 +708,7 @@ void main() {
'type': 'm.room.name', 'type': 'm.room.name',
'unsigned': {'age': 1234} 'unsigned': {'age': 1234}
}, room); }, room);
expect(await event.getLocalizedBodyAsync(MatrixDefaultLocalizations()), expect(await event.calcLocalizedBody(MatrixDefaultLocalizations()),
'Example changed the chat name to The room name'); 'Example changed the chat name to The room name');
expect(event.isEventTypeKnown, true); expect(event.isEventTypeKnown, true);
@ -722,7 +722,7 @@ void main() {
'type': 'm.room.topic', 'type': 'm.room.topic',
'unsigned': {'age': 1234} 'unsigned': {'age': 1234}
}, room); }, room);
expect(await event.getLocalizedBodyAsync(MatrixDefaultLocalizations()), expect(await event.calcLocalizedBody(MatrixDefaultLocalizations()),
'Example changed the chat description to A room topic'); 'Example changed the chat description to A room topic');
expect(event.isEventTypeKnown, true); expect(event.isEventTypeKnown, true);
@ -739,7 +739,7 @@ void main() {
'type': 'm.room.avatar', 'type': 'm.room.avatar',
'unsigned': {'age': 1234} 'unsigned': {'age': 1234}
}, room); }, room);
expect(await event.getLocalizedBodyAsync(MatrixDefaultLocalizations()), expect(await event.calcLocalizedBody(MatrixDefaultLocalizations()),
'Example changed the chat avatar'); 'Example changed the chat avatar');
expect(event.isEventTypeKnown, true); expect(event.isEventTypeKnown, true);
@ -753,7 +753,7 @@ void main() {
'type': 'm.room.history_visibility', 'type': 'm.room.history_visibility',
'unsigned': {'age': 1234} 'unsigned': {'age': 1234}
}, room); }, room);
expect(await event.getLocalizedBodyAsync(MatrixDefaultLocalizations()), expect(await event.calcLocalizedBody(MatrixDefaultLocalizations()),
'Example changed the history visibility to Visible for all participants'); 'Example changed the history visibility to Visible for all participants');
expect(event.isEventTypeKnown, true); expect(event.isEventTypeKnown, true);
@ -771,7 +771,7 @@ void main() {
'type': 'm.room.encryption', 'type': 'm.room.encryption',
'unsigned': {'age': 1234} 'unsigned': {'age': 1234}
}, room); }, room);
expect(await event.getLocalizedBodyAsync(MatrixDefaultLocalizations()), expect(await event.calcLocalizedBody(MatrixDefaultLocalizations()),
'Example activated end to end encryption. Need pantalaimon'); 'Example activated end to end encryption. Need pantalaimon');
expect(event.isEventTypeKnown, true); expect(event.isEventTypeKnown, true);
@ -789,7 +789,7 @@ void main() {
'type': 'm.room.message', 'type': 'm.room.message',
'unsigned': {'age': 1234} 'unsigned': {'age': 1234}
}, room); }, room);
expect(await event.getLocalizedBodyAsync(MatrixDefaultLocalizations()), expect(await event.calcLocalizedBody(MatrixDefaultLocalizations()),
'This is an example text message'); 'This is an example text message');
expect(event.isEventTypeKnown, true); expect(event.isEventTypeKnown, true);
@ -807,7 +807,7 @@ void main() {
'type': 'm.room.message', 'type': 'm.room.message',
'unsigned': {'age': 1234} 'unsigned': {'age': 1234}
}, room); }, room);
expect(await event.getLocalizedBodyAsync(MatrixDefaultLocalizations()), expect(await event.calcLocalizedBody(MatrixDefaultLocalizations()),
'* thinks this is an example emote'); '* thinks this is an example emote');
expect(event.isEventTypeKnown, true); expect(event.isEventTypeKnown, true);
@ -825,7 +825,7 @@ void main() {
'type': 'm.room.message', 'type': 'm.room.message',
'unsigned': {'age': 1234} 'unsigned': {'age': 1234}
}, room); }, room);
expect(await event.getLocalizedBodyAsync(MatrixDefaultLocalizations()), expect(await event.calcLocalizedBody(MatrixDefaultLocalizations()),
'This is an example notice'); 'This is an example notice');
expect(event.isEventTypeKnown, true); expect(event.isEventTypeKnown, true);
@ -843,7 +843,7 @@ void main() {
'type': 'm.room.message', 'type': 'm.room.message',
'unsigned': {'age': 1234} 'unsigned': {'age': 1234}
}, room); }, room);
expect(await event.getLocalizedBodyAsync(MatrixDefaultLocalizations()), expect(await event.calcLocalizedBody(MatrixDefaultLocalizations()),
'Example sent a picture'); 'Example sent a picture');
expect(event.isEventTypeKnown, true); expect(event.isEventTypeKnown, true);
@ -862,7 +862,7 @@ void main() {
'type': 'm.room.message', 'type': 'm.room.message',
'unsigned': {'age': 1234} 'unsigned': {'age': 1234}
}, room); }, room);
expect(await event.getLocalizedBodyAsync(MatrixDefaultLocalizations()), expect(await event.calcLocalizedBody(MatrixDefaultLocalizations()),
'Example sent a file'); 'Example sent a file');
expect(event.isEventTypeKnown, true); expect(event.isEventTypeKnown, true);
@ -884,7 +884,7 @@ void main() {
'type': 'm.room.message', 'type': 'm.room.message',
'unsigned': {'age': 1234} 'unsigned': {'age': 1234}
}, room); }, room);
expect(await event.getLocalizedBodyAsync(MatrixDefaultLocalizations()), expect(await event.calcLocalizedBody(MatrixDefaultLocalizations()),
'Example sent an audio'); 'Example sent an audio');
expect(event.isEventTypeKnown, true); expect(event.isEventTypeKnown, true);
@ -910,7 +910,7 @@ void main() {
'type': 'm.room.message', 'type': 'm.room.message',
'unsigned': {'age': 1234} 'unsigned': {'age': 1234}
}, room); }, room);
expect(await event.getLocalizedBodyAsync(MatrixDefaultLocalizations()), expect(await event.calcLocalizedBody(MatrixDefaultLocalizations()),
'Example shared the location'); 'Example shared the location');
expect(event.isEventTypeKnown, true); expect(event.isEventTypeKnown, true);
@ -941,7 +941,7 @@ void main() {
'type': 'm.room.message', 'type': 'm.room.message',
'unsigned': {'age': 1234} 'unsigned': {'age': 1234}
}, room); }, room);
expect(await event.getLocalizedBodyAsync(MatrixDefaultLocalizations()), expect(await event.calcLocalizedBody(MatrixDefaultLocalizations()),
'Example sent a video'); 'Example sent a video');
expect(event.isEventTypeKnown, true); expect(event.isEventTypeKnown, true);
@ -954,7 +954,7 @@ void main() {
'type': 'unknown.event.type', 'type': 'unknown.event.type',
'unsigned': {'age': 1234} 'unsigned': {'age': 1234}
}, room); }, room);
expect(await event.getLocalizedBodyAsync(MatrixDefaultLocalizations()), expect(await event.calcLocalizedBody(MatrixDefaultLocalizations()),
'Unknown event unknown.event.type'); 'Unknown event unknown.event.type');
expect(event.isEventTypeKnown, false); expect(event.isEventTypeKnown, false);
}); });
@ -977,7 +977,7 @@ void main() {
'unsigned': {'age': 1234} 'unsigned': {'age': 1234}
}, room); }, room);
expect( expect(
await event.getLocalizedBodyAsync(MatrixDefaultLocalizations(), await event.calcLocalizedBody(MatrixDefaultLocalizations(),
plaintextBody: true), plaintextBody: true),
'**This is an example text message**'); '**This is an example text message**');
@ -1006,11 +1006,11 @@ void main() {
'unsigned': {'age': 1234} 'unsigned': {'age': 1234}
}, room); }, room);
expect( expect(
await event.getLocalizedBodyAsync(MatrixDefaultLocalizations(), await event.calcLocalizedBody(MatrixDefaultLocalizations(),
hideEdit: true), hideEdit: true),
'This is an example text message'); 'This is an example text message');
expect( expect(
await event.getLocalizedBodyAsync(MatrixDefaultLocalizations(), await event.calcLocalizedBody(MatrixDefaultLocalizations(),
hideEdit: true, plaintextBody: true), hideEdit: true, plaintextBody: true),
'**This is an example text message**'); '**This is an example text message**');
@ -1029,11 +1029,11 @@ void main() {
'unsigned': {'age': 1234} 'unsigned': {'age': 1234}
}, room); }, room);
expect( expect(
await event.getLocalizedBodyAsync(MatrixDefaultLocalizations(), await event.calcLocalizedBody(MatrixDefaultLocalizations(),
hideReply: true), hideReply: true),
'hmm, fox'); 'hmm, fox');
expect( expect(
await event.getLocalizedBodyAsync(MatrixDefaultLocalizations(), await event.calcLocalizedBody(MatrixDefaultLocalizations(),
hideReply: true, plaintextBody: true), hideReply: true, plaintextBody: true),
'hmm, *fox*'); 'hmm, *fox*');
@ -1054,19 +1054,19 @@ void main() {
'unsigned': {'age': 1234} 'unsigned': {'age': 1234}
}, room); }, room);
expect( expect(
await event.getLocalizedBodyAsync(MatrixDefaultLocalizations(), await event.calcLocalizedBody(MatrixDefaultLocalizations(),
removeMarkdown: true), removeMarkdown: true),
'Title\nsome text and link\nokay and this is important'); 'Title\nsome text and link\nokay and this is important');
expect( expect(
await event.getLocalizedBodyAsync(MatrixDefaultLocalizations(), await event.calcLocalizedBody(MatrixDefaultLocalizations(),
removeMarkdown: true, plaintextBody: true), removeMarkdown: true, plaintextBody: true),
'Title\nsome text and 🔗link\nokay and this is important'); 'Title\nsome text and 🔗link\nokay and this is important');
expect( expect(
await event.getLocalizedBodyAsync(MatrixDefaultLocalizations(), await event.calcLocalizedBody(MatrixDefaultLocalizations(),
removeMarkdown: true, withSenderNamePrefix: true), removeMarkdown: true, withSenderNamePrefix: true),
'Example: Title\nsome text and link\nokay and this is important'); 'Example: Title\nsome text and link\nokay and this is important');
expect( expect(
await event.getLocalizedBodyAsync(MatrixDefaultLocalizations(), await event.calcLocalizedBody(MatrixDefaultLocalizations(),
removeMarkdown: true, removeMarkdown: true,
plaintextBody: true, plaintextBody: true,
withSenderNamePrefix: true), withSenderNamePrefix: true),

View File

@ -131,7 +131,8 @@ void main() {
] ]
} }
})); }));
expect((await user1.currentPresence).presence, PresenceType.online); expect(
(await user1.fetchCurrentPresence()).presence, PresenceType.online);
}); });
test('canBan', () async { test('canBan', () async {
expect(user1.canBan, false); expect(user1.canBan, false);