Merge branch 'krille/last-event-reactions' into 'main'
fix: Show reactions as last events and refactor hasNewMessage See merge request famedly/company/frontend/famedlysdk!960
This commit is contained in:
commit
d148cd0266
|
|
@ -1,3 +1,6 @@
|
||||||
|
## [0.8.7] - 14nd Feb 2022
|
||||||
|
- fix: Show reactions as last events and refactor hasNewMessage
|
||||||
|
|
||||||
## [0.8.6] - 14nd Feb 2022
|
## [0.8.6] - 14nd Feb 2022
|
||||||
- feat: Add hasNewMessages flag to room
|
- feat: Add hasNewMessages flag to room
|
||||||
- fix: Sort rooms after updating the UI on web
|
- fix: Sort rooms after updating the UI on web
|
||||||
|
|
|
||||||
|
|
@ -190,6 +190,7 @@ class Client extends MatrixApi {
|
||||||
EventTypes.Message,
|
EventTypes.Message,
|
||||||
EventTypes.Encrypted,
|
EventTypes.Encrypted,
|
||||||
EventTypes.Sticker,
|
EventTypes.Sticker,
|
||||||
|
EventTypes.Reaction,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// register all the default commands
|
// register all the default commands
|
||||||
|
|
|
||||||
|
|
@ -167,11 +167,7 @@ class Room {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final isMessageEvent = [
|
final isMessageEvent = client.roomPreviewLastEvents.contains(state.type);
|
||||||
EventTypes.Message,
|
|
||||||
EventTypes.Sticker,
|
|
||||||
EventTypes.Encrypted,
|
|
||||||
].contains(state.type);
|
|
||||||
|
|
||||||
// We ignore events editing events older than the current-latest here so
|
// We ignore events editing events older than the current-latest here so
|
||||||
// i.e. newly sent edits for older events don't show up in room preview
|
// i.e. newly sent edits for older events don't show up in room preview
|
||||||
|
|
@ -514,9 +510,19 @@ class Room {
|
||||||
/// Checks if the last event has a read marker of the user.
|
/// Checks if the last event has a read marker of the user.
|
||||||
bool get hasNewMessages {
|
bool get hasNewMessages {
|
||||||
final lastEvent = this.lastEvent;
|
final lastEvent = this.lastEvent;
|
||||||
return lastEvent != null &&
|
|
||||||
!lastEvent.receipts
|
// There is no known event or the last event is only a state fallback event,
|
||||||
.any((receipt) => receipt.user.senderId == client.userID!);
|
// we assume there is no new messages.
|
||||||
|
if (lastEvent == null ||
|
||||||
|
!client.roomPreviewLastEvents.contains(lastEvent.type)) return false;
|
||||||
|
|
||||||
|
// Read marker is on the last event so no new messages.
|
||||||
|
if (lastEvent.receipts
|
||||||
|
.any((receipt) => receipt.user.senderId == client.userID!)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns true if this room is unread. To check if there are new messages
|
/// Returns true if this room is unread. To check if there are new messages
|
||||||
|
|
|
||||||
|
|
@ -213,7 +213,12 @@ abstract class EventLocalizations {
|
||||||
_localizedBodyNormalMessage(event, i18n, body),
|
_localizedBodyNormalMessage(event, i18n, body),
|
||||||
EventTypes.Message: (event, i18n, body) =>
|
EventTypes.Message: (event, i18n, body) =>
|
||||||
_localizedBodyNormalMessage(event, i18n, body),
|
_localizedBodyNormalMessage(event, i18n, body),
|
||||||
EventTypes.Reaction: (event, i18n, body) =>
|
EventTypes.Reaction: (event, i18n, body) => i18n.sentReaction(
|
||||||
_localizedBodyNormalMessage(event, i18n, body),
|
event.sender.calcDisplayname(),
|
||||||
|
event.content
|
||||||
|
.tryGetMap<String, dynamic>('m.relates_to')
|
||||||
|
?.tryGet<String>('key') ??
|
||||||
|
body,
|
||||||
|
),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -122,6 +122,8 @@ abstract class MatrixLocalizations {
|
||||||
|
|
||||||
String sentAVideo(String senderName);
|
String sentAVideo(String senderName);
|
||||||
|
|
||||||
|
String sentReaction(String senderName, String reactionKey);
|
||||||
|
|
||||||
String sharedTheLocation(String senderName);
|
String sharedTheLocation(String senderName);
|
||||||
|
|
||||||
String couldNotDecryptMessage(String errorText);
|
String couldNotDecryptMessage(String errorText);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
name: matrix
|
name: matrix
|
||||||
description: Matrix Dart SDK
|
description: Matrix Dart SDK
|
||||||
version: 0.8.6
|
version: 0.8.7
|
||||||
homepage: https://famedly.com
|
homepage: https://famedly.com
|
||||||
repository: https://gitlab.com/famedly/company/frontend/famedlysdk.git
|
repository: https://gitlab.com/famedly/company/frontend/famedlysdk.git
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -225,4 +225,9 @@ class MatrixDefaultLocalizations extends MatrixLocalizations {
|
||||||
String startedACall(String senderName) {
|
String startedACall(String senderName) {
|
||||||
return 'startedACall';
|
return 'startedACall';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
String sentReaction(String senderName, String reactionKey) {
|
||||||
|
return '$senderName reacted with $reactionKey';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -258,6 +258,26 @@ void main() {
|
||||||
expect(room.lastEvent?.eventId, '5');
|
expect(room.lastEvent?.eventId, '5');
|
||||||
expect(room.lastEvent?.body, 'edited cdc');
|
expect(room.lastEvent?.body, 'edited cdc');
|
||||||
expect(room.lastEvent?.status, EventStatus.sent);
|
expect(room.lastEvent?.status, EventStatus.sent);
|
||||||
|
// Are reactions coming through?
|
||||||
|
room.setState(
|
||||||
|
Event(
|
||||||
|
senderId: '@test:example.com',
|
||||||
|
type: EventTypes.Reaction,
|
||||||
|
room: room,
|
||||||
|
eventId: '123456',
|
||||||
|
originServerTs: DateTime.now(),
|
||||||
|
content: {
|
||||||
|
'm.relates_to': {
|
||||||
|
'rel_type': RelationshipTypes.reaction,
|
||||||
|
'event_id': '1234',
|
||||||
|
'key': ':-)',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
stateKey: '',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
expect(room.lastEvent?.eventId, '123456');
|
||||||
|
expect(room.lastEvent?.type, EventTypes.Reaction);
|
||||||
});
|
});
|
||||||
test('lastEvent when reply parent edited', () async {
|
test('lastEvent when reply parent edited', () async {
|
||||||
room.setState(
|
room.setState(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue