mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-12-24 14:32:37 +01:00
Merge branch 'krille/collapse-room-create-states' into 'main'
feat: Collapse room create states See merge request ChristianPauly/fluffychat-flutter!294
This commit is contained in:
commit
500fbbf8c6
@ -37,6 +37,12 @@ class Message extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (event.type == EventTypes.RoomCreate) {
|
||||
return InkWell(
|
||||
onTap: () => onSelect(event),
|
||||
child: StateMessage(event),
|
||||
);
|
||||
}
|
||||
if (![EventTypes.Message, EventTypes.Sticker, EventTypes.Encrypted]
|
||||
.contains(event.type)) {
|
||||
return StateMessage(event);
|
||||
|
@ -18,9 +18,9 @@ class StateMessage extends StatelessWidget {
|
||||
),
|
||||
child: Center(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(4),
|
||||
padding: const EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).backgroundColor.withOpacity(0.8),
|
||||
color: Theme.of(context).secondaryHeaderColor.withOpacity(0.9),
|
||||
borderRadius: BorderRadius.circular(7),
|
||||
),
|
||||
child: Text(
|
||||
|
@ -87,6 +87,8 @@ class _ChatState extends State<_Chat> {
|
||||
|
||||
List<Event> selectedEvents = [];
|
||||
|
||||
bool _collapseRoomCreate = true;
|
||||
|
||||
Event replyEvent;
|
||||
|
||||
Event editEvent;
|
||||
@ -429,20 +431,35 @@ class _ChatState extends State<_Chat> {
|
||||
_updateScrollController();
|
||||
}
|
||||
|
||||
List<Event> getFilteredEvents() => timeline.events
|
||||
.where((e) =>
|
||||
// always filter out edit and reaction relationships
|
||||
!{RelationshipTypes.Edit, RelationshipTypes.Reaction}
|
||||
.contains(e.relationshipType) &&
|
||||
// always filter out m.key.* events
|
||||
!e.type.startsWith('m.key.verification.') &&
|
||||
// if a reaction has been redacted we also want it to appear in the timeline
|
||||
e.type != EventTypes.Reaction &&
|
||||
// if we enabled to hide all redacted events, don't show those
|
||||
(!AppConfig.hideRedactedEvents || !e.redacted) &&
|
||||
// if we enabled to hide all unknown events, don't show those
|
||||
(!AppConfig.hideUnknownEvents || e.isEventTypeKnown))
|
||||
.toList();
|
||||
List<Event> getFilteredEvents() {
|
||||
final filteredEvents = timeline.events
|
||||
.where((e) =>
|
||||
// always filter out edit and reaction relationships
|
||||
!{RelationshipTypes.Edit, RelationshipTypes.Reaction}
|
||||
.contains(e.relationshipType) &&
|
||||
// always filter out m.key.* events
|
||||
!e.type.startsWith('m.key.verification.') &&
|
||||
// if a reaction has been redacted we also want it to appear in the timeline
|
||||
e.type != EventTypes.Reaction &&
|
||||
// if we enabled to hide all redacted events, don't show those
|
||||
(!AppConfig.hideRedactedEvents || !e.redacted) &&
|
||||
// if we enabled to hide all unknown events, don't show those
|
||||
(!AppConfig.hideUnknownEvents || e.isEventTypeKnown))
|
||||
.toList();
|
||||
|
||||
// Hide state events from the room creater right after the room created event
|
||||
if (_collapseRoomCreate &&
|
||||
filteredEvents[filteredEvents.length - 1].type ==
|
||||
EventTypes.RoomCreate) {
|
||||
while (filteredEvents[filteredEvents.length - 2].senderId ==
|
||||
filteredEvents[filteredEvents.length - 1].senderId &&
|
||||
![EventTypes.Message, EventTypes.Sticker, EventTypes.Encrypted]
|
||||
.contains(filteredEvents[filteredEvents.length - 2].type)) {
|
||||
filteredEvents.removeAt(filteredEvents.length - 2);
|
||||
}
|
||||
}
|
||||
return filteredEvents;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -722,6 +739,12 @@ class _ChatState extends State<_Chat> {
|
||||
),
|
||||
),
|
||||
onSelect: (Event event) {
|
||||
if (event.type ==
|
||||
EventTypes.RoomCreate) {
|
||||
return setState(() =>
|
||||
_collapseRoomCreate =
|
||||
false);
|
||||
}
|
||||
if (!event.redacted) {
|
||||
if (selectedEvents
|
||||
.contains(event)) {
|
||||
|
Loading…
Reference in New Issue
Block a user