chore: Follow up nicer state events

This commit is contained in:
Christian Pauly 2022-10-15 11:11:36 +02:00
parent c365469dc5
commit 7e4a4c88be
3 changed files with 31 additions and 49 deletions

View File

@ -28,7 +28,7 @@
"type": "text",
"placeholders": {}
},
"acceptedTheInvitation": "{username} accepted the invitation",
"acceptedTheInvitation": "👍 {username} accepted the invitation",
"@acceptedTheInvitation": {
"type": "text",
"placeholders": {
@ -45,7 +45,7 @@
"type": "text",
"placeholders": {}
},
"activatedEndToEndEncryption": "{username} activated end to end encryption",
"activatedEndToEndEncryption": "🔐 {username} activated end to end encryption",
"@activatedEndToEndEncryption": {
"type": "text",
"placeholders": {
@ -702,7 +702,7 @@
"type": "text",
"placeholders": {}
},
"createdTheChat": "{username} created the chat",
"createdTheChat": "💬 {username} created the chat",
"@createdTheChat": {
"type": "text",
"placeholders": {
@ -1209,7 +1209,7 @@
"type": "text",
"placeholders": {}
},
"invitedUser": "{username} invited {targetName}",
"invitedUser": "📩 {username} invited {targetName}",
"@invitedUser": {
"type": "text",
"placeholders": {
@ -1245,7 +1245,7 @@
"type": "text",
"placeholders": {}
},
"joinedTheChat": "{username} joined the chat",
"joinedTheChat": "👋 {username} joined the chat",
"@joinedTheChat": {
"type": "text",
"placeholders": {
@ -1267,7 +1267,7 @@
"type": "text",
"placeholders": {}
},
"kicked": "{username} kicked {targetName}",
"kicked": "👞 {username} kicked {targetName}",
"@kicked": {
"type": "text",
"placeholders": {
@ -1275,7 +1275,7 @@
"targetName": {}
}
},
"kickedAndBanned": "{username} kicked and banned {targetName}",
"kickedAndBanned": "🙅 {username} kicked and banned {targetName}",
"@kickedAndBanned": {
"type": "text",
"placeholders": {
@ -2452,7 +2452,7 @@
"username": {}
}
},
"userLeftTheChat": "{username} left the chat",
"userLeftTheChat": "🚪 {username} left the chat",
"@userLeftTheChat": {
"type": "text",
"placeholders": {
@ -2837,7 +2837,7 @@
"@youRejectedTheInvitation": {},
"youJoinedTheChat": "You joined the chat",
"@youJoinedTheChat": {},
"youAcceptedTheInvitation": "You accepted the invitation",
"youAcceptedTheInvitation": "👍 You accepted the invitation",
"@youAcceptedTheInvitation": {},
"youBannedUser": "You banned {user}",
"@youBannedUser": {
@ -2851,25 +2851,25 @@
"user": {}
}
},
"youInvitedBy": "You have been invited by {user}",
"youInvitedBy": "📩 You have been invited by {user}",
"@youInvitedBy": {
"placeholders": {
"user": {}
}
},
"youInvitedUser": "You invited {user}",
"youInvitedUser": "📩 You invited {user}",
"@youInvitedUser": {
"placeholders": {
"user": {}
}
},
"youKicked": "You kicked {user}",
"youKicked": "👞 You kicked {user}",
"@youKicked": {
"placeholders": {
"user": {}
}
},
"youKickedAndBanned": "You kicked and banned {user}",
"youKickedAndBanned": "🙅 You kicked and banned {user}",
"@youKickedAndBanned": {
"placeholders": {
"user": {}

View File

@ -12,11 +12,6 @@ class StateMessage extends StatelessWidget {
@override
Widget build(BuildContext context) {
if (event.unsigned!['im.fluffychat.collapsed_state_event'] == true) {
return Container();
}
final int counter =
event.unsigned!['im.fluffychat.collapsed_state_event_count'] ?? 0;
return Padding(
padding: const EdgeInsets.symmetric(
horizontal: 8.0,
@ -26,41 +21,26 @@ class StateMessage extends StatelessWidget {
child: Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
color: Theme.of(context).brightness == Brightness.light
? Colors.white
: Colors.grey.shade900,
color: Theme.of(context).colorScheme.secondaryContainer,
borderRadius: BorderRadius.circular(AppConfig.borderRadius / 2),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
FutureBuilder<String>(
future:
event.calcLocalizedBody(MatrixLocals(L10n.of(context)!)),
builder: (context, snapshot) {
return Text(
snapshot.data ??
event.calcLocalizedBodyFallback(
MatrixLocals(L10n.of(context)!)),
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 14 * AppConfig.fontSizeFactor,
color: Theme.of(context).textTheme.bodyText2!.color,
decoration:
event.redacted ? TextDecoration.lineThrough : null,
child: FutureBuilder<String>(
future: event.calcLocalizedBody(MatrixLocals(L10n.of(context)!)),
builder: (context, snapshot) {
return Text(
snapshot.data ??
event.calcLocalizedBodyFallback(
MatrixLocals(L10n.of(context)!),
),
);
}),
if (counter != 0)
Text(
L10n.of(context)!.moreEvents(counter),
textAlign: TextAlign.center,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 14 * AppConfig.fontSizeFactor,
color: Theme.of(context).colorScheme.onSecondaryContainer,
decoration:
event.redacted ? TextDecoration.lineThrough : null,
),
),
],
),
);
}),
),
),
);

View File

@ -22,10 +22,12 @@ extension IsStateExtension on Event {
(!AppConfig.hideUnimportantStateEvents ||
!isState ||
importantStateEvents.contains(type)) &&
// hide member events in public rooms
// hide simple join/leave member events in public rooms
(!AppConfig.hideUnimportantStateEvents ||
type != EventTypes.RoomMember ||
room.joinRules != JoinRules.public);
room.joinRules != JoinRules.public ||
content.tryGet<String>('membership') == 'ban' ||
stateKey != senderId);
static const Set<String> importantStateEvents = {
EventTypes.Encryption,