chore: Only load last event sender if necessary
This commit is contained in:
parent
5829446afa
commit
147a741aef
1 changed files with 48 additions and 27 deletions
|
|
@ -89,6 +89,11 @@ class ChatListItem extends StatelessWidget {
|
||||||
if (filter != null && !displayname.toLowerCase().contains(filter)) {
|
if (filter != null && !displayname.toLowerCase().contains(filter)) {
|
||||||
return const SizedBox.shrink();
|
return const SizedBox.shrink();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final needLastEventSender = lastEvent == null
|
||||||
|
? false
|
||||||
|
: room.getState(EventTypes.RoomMember, lastEvent.senderId) == null;
|
||||||
|
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
horizontal: 8,
|
horizontal: 8,
|
||||||
|
|
@ -226,33 +231,49 @@ class ChatListItem extends StatelessWidget {
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
softWrap: false,
|
softWrap: false,
|
||||||
)
|
)
|
||||||
: Text(
|
: FutureBuilder(
|
||||||
room.membership == Membership.invite
|
future: needLastEventSender
|
||||||
? isDirectChat
|
? room.lastEvent?.calcLocalizedBody(
|
||||||
? L10n.of(context)!.invitePrivateChat
|
MatrixLocals(L10n.of(context)!),
|
||||||
: L10n.of(context)!.inviteGroupChat
|
hideReply: true,
|
||||||
: room.lastEvent?.calcLocalizedBodyFallback(
|
hideEdit: true,
|
||||||
MatrixLocals(L10n.of(context)!),
|
plaintextBody: true,
|
||||||
hideReply: true,
|
removeMarkdown: true,
|
||||||
hideEdit: true,
|
withSenderNamePrefix: !isDirectChat ||
|
||||||
plaintextBody: true,
|
directChatMatrixId !=
|
||||||
removeMarkdown: true,
|
room.lastEvent?.senderId,
|
||||||
withSenderNamePrefix: !isDirectChat ||
|
)
|
||||||
directChatMatrixId !=
|
: null,
|
||||||
room.lastEvent?.senderId,
|
initialData:
|
||||||
) ??
|
room.lastEvent?.calcLocalizedBodyFallback(
|
||||||
L10n.of(context)!.emptyChat,
|
MatrixLocals(L10n.of(context)!),
|
||||||
softWrap: false,
|
hideReply: true,
|
||||||
maxLines: 1,
|
hideEdit: true,
|
||||||
overflow: TextOverflow.ellipsis,
|
plaintextBody: true,
|
||||||
style: TextStyle(
|
removeMarkdown: true,
|
||||||
fontWeight: unread || room.hasNewMessages
|
withSenderNamePrefix: !isDirectChat ||
|
||||||
? FontWeight.bold
|
directChatMatrixId !=
|
||||||
: null,
|
room.lastEvent?.senderId,
|
||||||
color: theme.colorScheme.onSurfaceVariant,
|
),
|
||||||
decoration: room.lastEvent?.redacted == true
|
builder: (context, snapshot) => Text(
|
||||||
? TextDecoration.lineThrough
|
room.membership == Membership.invite
|
||||||
: null,
|
? isDirectChat
|
||||||
|
? L10n.of(context)!.invitePrivateChat
|
||||||
|
: L10n.of(context)!.inviteGroupChat
|
||||||
|
: snapshot.data ??
|
||||||
|
L10n.of(context)!.emptyChat,
|
||||||
|
softWrap: false,
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: unread || room.hasNewMessages
|
||||||
|
? FontWeight.bold
|
||||||
|
: null,
|
||||||
|
color: theme.colorScheme.onSurfaceVariant,
|
||||||
|
decoration: room.lastEvent?.redacted == true
|
||||||
|
? TextDecoration.lineThrough
|
||||||
|
: null,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue