mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-12-25 23:12:37 +01:00
feat: Collapse room create states
This commit is contained in:
parent
d9590dd4e8
commit
fc0c0386e2
@ -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,7 +431,8 @@ class _ChatState extends State<_Chat> {
|
|||||||
_updateScrollController();
|
_updateScrollController();
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Event> getFilteredEvents() => timeline.events
|
List<Event> getFilteredEvents() {
|
||||||
|
final filteredEvents = timeline.events
|
||||||
.where((e) =>
|
.where((e) =>
|
||||||
// always filter out edit and reaction relationships
|
// always filter out edit and reaction relationships
|
||||||
!{RelationshipTypes.Edit, RelationshipTypes.Reaction}
|
!{RelationshipTypes.Edit, RelationshipTypes.Reaction}
|
||||||
@ -444,6 +447,20 @@ class _ChatState extends State<_Chat> {
|
|||||||
(!AppConfig.hideUnknownEvents || e.isEventTypeKnown))
|
(!AppConfig.hideUnknownEvents || e.isEventTypeKnown))
|
||||||
.toList();
|
.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) {
|
||||||
matrix = Matrix.of(context);
|
matrix = Matrix.of(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