Merge branch 'soru/fix-load-member-in-timeline' into 'main'

fix: Properly re-render the timeline etc. when the full userinformation was fetched

See merge request famedly/fluffychat!500
This commit is contained in:
Krille Fear 2021-09-06 18:25:53 +00:00
commit 6d5e06a723

View File

@ -57,13 +57,16 @@ class ChatView extends StatelessWidget {
} }
return VWidgetGuard( return VWidgetGuard(
onSystemPop: (redirector) async { onSystemPop: (redirector) async {
if (controller.selectedEvents.isNotEmpty) { if (controller.selectedEvents.isNotEmpty) {
controller.clearSelectedEvents(); controller.clearSelectedEvents();
redirector.stopRedirection(); redirector.stopRedirection();
} }
}, },
child: Scaffold( child: StreamBuilder(
stream: controller.room.onUpdate.stream
.rateLimit(Duration(milliseconds: 250)),
builder: (context, snapshot) => Scaffold(
appBar: AppBar( appBar: AppBar(
actionsIconTheme: IconThemeData( actionsIconTheme: IconThemeData(
color: controller.selectedEvents.isEmpty color: controller.selectedEvents.isEmpty
@ -80,73 +83,67 @@ class ChatView extends StatelessWidget {
: UnreadBadgeBackButton(roomId: controller.roomId), : UnreadBadgeBackButton(roomId: controller.roomId),
titleSpacing: 0, titleSpacing: 0,
title: controller.selectedEvents.isEmpty title: controller.selectedEvents.isEmpty
? StreamBuilder( ? ListTile(
stream: controller.room.onUpdate.stream leading: Avatar(
.rateLimit(Duration(milliseconds: 250)), controller.room.avatar, controller.room.displayname),
builder: (context, snapshot) => ListTile( contentPadding: EdgeInsets.zero,
leading: Avatar(controller.room.avatar, onTap: controller.room.isDirectChat
controller.room.displayname), ? () => showModalBottomSheet(
contentPadding: EdgeInsets.zero, context: context,
onTap: controller.room.isDirectChat builder: (c) => UserBottomSheet(
? () => showModalBottomSheet( user: controller.room.getUserByMXIDSync(
context: context, controller.room.directChatMatrixID),
builder: (c) => UserBottomSheet( outerContext: context,
user: controller.room.getUserByMXIDSync( onMention: () => controller
controller.room.directChatMatrixID), .sendController.text +=
outerContext: context, '${controller.room.getUserByMXIDSync(controller.room.directChatMatrixID).mention} ',
onMention: () => controller ),
.sendController.text += )
'${controller.room.getUserByMXIDSync(controller.room.directChatMatrixID).mention} ', : () => VRouter.of(context).toSegments(
), ['rooms', controller.room.id, 'details']),
) title: Text(
: () => VRouter.of(context).toSegments( controller.room.getLocalizedDisplayname(
['rooms', controller.room.id, 'details']), MatrixLocals(L10n.of(context))),
title: Text( maxLines: 1),
controller.room.getLocalizedDisplayname( subtitle: controller.room
MatrixLocals(L10n.of(context))), .getLocalizedTypingText(context)
maxLines: 1), .isEmpty
subtitle: controller.room ? StreamBuilder<Object>(
.getLocalizedTypingText(context) stream: Matrix.of(context)
.isEmpty .client
? StreamBuilder<Object>( .onPresence
stream: Matrix.of(context) .stream
.client .where((p) =>
.onPresence p.senderId ==
.stream controller.room.directChatMatrixID)
.where((p) => .rateLimit(Duration(seconds: 1)),
p.senderId == builder: (context, snapshot) => Text(
controller.room.directChatMatrixID) controller.room.getLocalizedStatus(context),
.rateLimit(Duration(seconds: 1)), maxLines: 1,
builder: (context, snapshot) => Text( //overflow: TextOverflow.ellipsis,
controller.room ))
.getLocalizedStatus(context), : Row(
maxLines: 1, children: <Widget>[
//overflow: TextOverflow.ellipsis, Icon(Icons.edit_outlined,
)) color:
: Row( Theme.of(context).colorScheme.secondary,
children: <Widget>[ size: 13),
Icon(Icons.edit_outlined, SizedBox(width: 4),
color: Theme.of(context) Expanded(
.colorScheme child: Text(
.secondary, controller.room
size: 13), .getLocalizedTypingText(context),
SizedBox(width: 4), maxLines: 1,
Expanded( style: TextStyle(
child: Text( color:
controller.room Theme.of(context).colorScheme.secondary,
.getLocalizedTypingText(context), fontStyle: FontStyle.italic,
maxLines: 1, ),
style: TextStyle(
color: Theme.of(context)
.colorScheme
.secondary,
fontStyle: FontStyle.italic,
),
),
),
],
), ),
)) ),
],
),
)
: Text(controller.selectedEvents.length.toString()), : Text(controller.selectedEvents.length.toString()),
actions: controller.selectMode actions: controller.selectMode
? <Widget>[ ? <Widget>[
@ -261,6 +258,13 @@ class ChatView extends StatelessWidget {
thisEventsKeyMap[ thisEventsKeyMap[
controller.filteredEvents[i].eventId] = i; controller.filteredEvents[i].eventId] = i;
} }
final seenByText =
controller.room.getLocalizedSeenByText(
context,
controller.timeline,
controller.filteredEvents,
controller.unfolded,
);
return ListView.custom( return ListView.custom(
padding: EdgeInsets.only( padding: EdgeInsets.only(
@ -296,66 +300,44 @@ class ChatView extends StatelessWidget {
) )
: Container() : Container()
: i == 0 : i == 0
? StreamBuilder( ? AnimatedContainer(
stream: controller height: seenByText.isEmpty ? 0 : 24,
.room.onUpdate.stream duration: seenByText.isEmpty
.rateLimit(Duration( ? Duration(milliseconds: 0)
milliseconds: 250)), : Duration(milliseconds: 300),
builder: (_, __) { alignment: controller.filteredEvents
final seenByText = controller.room .isNotEmpty &&
.getLocalizedSeenByText( controller.filteredEvents
context, .first.senderId ==
controller.timeline, client.userID
controller.filteredEvents, ? Alignment.topRight
controller.unfolded, : Alignment.topLeft,
); padding: EdgeInsets.only(
return AnimatedContainer( left: 8,
height: right: 8,
seenByText.isEmpty ? 0 : 24, bottom: 8,
duration: seenByText.isEmpty ),
? Duration(milliseconds: 0) child: Container(
: Duration( padding: EdgeInsets.symmetric(
milliseconds: 300), horizontal: 4),
alignment: controller decoration: BoxDecoration(
.filteredEvents color: Theme.of(context)
.isNotEmpty && .scaffoldBackgroundColor
controller .withOpacity(0.8),
.filteredEvents borderRadius:
.first BorderRadius.circular(4),
.senderId == ),
client.userID child: Text(
? Alignment.topRight seenByText,
: Alignment.topLeft, maxLines: 1,
padding: EdgeInsets.only( overflow: TextOverflow.ellipsis,
left: 8, style: TextStyle(
right: 8, color: Theme.of(context)
bottom: 8, .colorScheme
.secondary,
), ),
child: Container( ),
padding: EdgeInsets.symmetric( ),
horizontal: 4),
decoration: BoxDecoration(
color: Theme.of(context)
.scaffoldBackgroundColor
.withOpacity(0.8),
borderRadius:
BorderRadius.circular(
4),
),
child: Text(
seenByText,
maxLines: 1,
overflow:
TextOverflow.ellipsis,
style: TextStyle(
color: Theme.of(context)
.colorScheme
.secondary,
),
),
),
);
},
) )
: AutoScrollTag( : AutoScrollTag(
key: ValueKey(controller key: ValueKey(controller
@ -773,7 +755,9 @@ class ChatView extends StatelessWidget {
), ),
], ],
), ),
)); ),
),
);
} }
} }