2021-06-18 08:29:48 +00:00
|
|
|
import 'package:matrix/matrix.dart';
|
2020-12-23 10:23:19 +00:00
|
|
|
|
2021-05-22 07:24:39 +00:00
|
|
|
import '../../config/app_config.dart';
|
2020-12-23 10:23:19 +00:00
|
|
|
|
2022-10-15 08:38:06 +00:00
|
|
|
extension IsStateExtension on Event {
|
|
|
|
bool get isVisibleInGui =>
|
|
|
|
// always filter out edit and reaction relationships
|
|
|
|
!{RelationshipTypes.edit, RelationshipTypes.reaction}
|
|
|
|
.contains(relationshipType) &&
|
|
|
|
// always filter out m.key.* events
|
|
|
|
!type.startsWith('m.key.verification.') &&
|
|
|
|
// event types to hide: redaction and reaction events
|
|
|
|
// if a reaction has been redacted we also want it to be hidden in the timeline
|
|
|
|
!{EventTypes.Reaction, EventTypes.Redaction}.contains(type) &&
|
|
|
|
// if we enabled to hide all redacted events, don't show those
|
|
|
|
(!AppConfig.hideRedactedEvents || !redacted) &&
|
|
|
|
// if we enabled to hide all unknown events, don't show those
|
|
|
|
(!AppConfig.hideUnknownEvents || isEventTypeKnown) &&
|
|
|
|
// remove state events that we don't want to render
|
|
|
|
(isState || !AppConfig.hideAllStateEvents) &&
|
|
|
|
// hide unimportant state events
|
|
|
|
(!AppConfig.hideUnimportantStateEvents ||
|
|
|
|
!isState ||
|
|
|
|
importantStateEvents.contains(type)) &&
|
2022-10-15 09:11:36 +00:00
|
|
|
// hide simple join/leave member events in public rooms
|
2022-10-15 08:38:06 +00:00
|
|
|
(!AppConfig.hideUnimportantStateEvents ||
|
|
|
|
type != EventTypes.RoomMember ||
|
2022-10-15 09:11:36 +00:00
|
|
|
room.joinRules != JoinRules.public ||
|
|
|
|
content.tryGet<String>('membership') == 'ban' ||
|
|
|
|
stateKey != senderId);
|
2020-12-23 10:23:19 +00:00
|
|
|
|
2022-10-15 08:38:06 +00:00
|
|
|
static const Set<String> importantStateEvents = {
|
|
|
|
EventTypes.Encryption,
|
|
|
|
EventTypes.RoomCreate,
|
|
|
|
EventTypes.RoomMember,
|
|
|
|
EventTypes.RoomTombstone,
|
|
|
|
EventTypes.CallInvite,
|
|
|
|
};
|
2021-02-25 08:11:17 +00:00
|
|
|
|
|
|
|
bool get isState => !{
|
|
|
|
EventTypes.Message,
|
|
|
|
EventTypes.Sticker,
|
|
|
|
EventTypes.Encrypted
|
|
|
|
}.contains(type);
|
|
|
|
}
|