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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
if (event.type == EventTypes.RoomCreate) {
|
||||||
|
return InkWell(
|
||||||
|
onTap: () => onSelect(event),
|
||||||
|
child: StateMessage(event),
|
||||||
|
);
|
||||||
|
}
|
||||||
if (![EventTypes.Message, EventTypes.Sticker, EventTypes.Encrypted]
|
if (![EventTypes.Message, EventTypes.Sticker, EventTypes.Encrypted]
|
||||||
.contains(event.type)) {
|
.contains(event.type)) {
|
||||||
return StateMessage(event);
|
return StateMessage(event);
|
||||||
|
@ -18,9 +18,9 @@ class StateMessage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.all(4),
|
padding: const EdgeInsets.all(8),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Theme.of(context).backgroundColor.withOpacity(0.8),
|
color: Theme.of(context).secondaryHeaderColor.withOpacity(0.9),
|
||||||
borderRadius: BorderRadius.circular(7),
|
borderRadius: BorderRadius.circular(7),
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
|
@ -87,6 +87,8 @@ class _ChatState extends State<_Chat> {
|
|||||||
|
|
||||||
List<Event> selectedEvents = [];
|
List<Event> selectedEvents = [];
|
||||||
|
|
||||||
|
bool _collapseRoomCreate = true;
|
||||||
|
|
||||||
Event replyEvent;
|
Event replyEvent;
|
||||||
|
|
||||||
Event editEvent;
|
Event editEvent;
|
||||||
@ -429,20 +431,35 @@ class _ChatState extends State<_Chat> {
|
|||||||
_updateScrollController();
|
_updateScrollController();
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Event> getFilteredEvents() => timeline.events
|
List<Event> getFilteredEvents() {
|
||||||
.where((e) =>
|
final filteredEvents = timeline.events
|
||||||
// always filter out edit and reaction relationships
|
.where((e) =>
|
||||||
!{RelationshipTypes.Edit, RelationshipTypes.Reaction}
|
// always filter out edit and reaction relationships
|
||||||
.contains(e.relationshipType) &&
|
!{RelationshipTypes.Edit, RelationshipTypes.Reaction}
|
||||||
// always filter out m.key.* events
|
.contains(e.relationshipType) &&
|
||||||
!e.type.startsWith('m.key.verification.') &&
|
// always filter out m.key.* events
|
||||||
// if a reaction has been redacted we also want it to appear in the timeline
|
!e.type.startsWith('m.key.verification.') &&
|
||||||
e.type != EventTypes.Reaction &&
|
// if a reaction has been redacted we also want it to appear in the timeline
|
||||||
// if we enabled to hide all redacted events, don't show those
|
e.type != EventTypes.Reaction &&
|
||||||
(!AppConfig.hideRedactedEvents || !e.redacted) &&
|
// if we enabled to hide all redacted events, don't show those
|
||||||
// if we enabled to hide all unknown events, don't show those
|
(!AppConfig.hideRedactedEvents || !e.redacted) &&
|
||||||
(!AppConfig.hideUnknownEvents || e.isEventTypeKnown))
|
// if we enabled to hide all unknown events, don't show those
|
||||||
.toList();
|
(!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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -722,6 +739,12 @@ class _ChatState extends State<_Chat> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
onSelect: (Event event) {
|
onSelect: (Event event) {
|
||||||
|
if (event.type ==
|
||||||
|
EventTypes.RoomCreate) {
|
||||||
|
return setState(() =>
|
||||||
|
_collapseRoomCreate =
|
||||||
|
false);
|
||||||
|
}
|
||||||
if (!event.redacted) {
|
if (!event.redacted) {
|
||||||
if (selectedEvents
|
if (selectedEvents
|
||||||
.contains(event)) {
|
.contains(event)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user