mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-12-25 06:52:35 +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,7 +431,8 @@ class _ChatState extends State<_Chat> {
|
||||
_updateScrollController();
|
||||
}
|
||||
|
||||
List<Event> getFilteredEvents() => timeline.events
|
||||
List<Event> getFilteredEvents() {
|
||||
final filteredEvents = timeline.events
|
||||
.where((e) =>
|
||||
// always filter out edit and reaction relationships
|
||||
!{RelationshipTypes.Edit, RelationshipTypes.Reaction}
|
||||
@ -444,6 +447,20 @@ class _ChatState extends State<_Chat> {
|
||||
(!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) {
|
||||
matrix = Matrix.of(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