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,12 +231,9 @@ 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
|
|
||||||
: L10n.of(context)!.inviteGroupChat
|
|
||||||
: room.lastEvent?.calcLocalizedBodyFallback(
|
|
||||||
MatrixLocals(L10n.of(context)!),
|
MatrixLocals(L10n.of(context)!),
|
||||||
hideReply: true,
|
hideReply: true,
|
||||||
hideEdit: true,
|
hideEdit: true,
|
||||||
|
|
@ -240,7 +242,25 @@ class ChatListItem extends StatelessWidget {
|
||||||
withSenderNamePrefix: !isDirectChat ||
|
withSenderNamePrefix: !isDirectChat ||
|
||||||
directChatMatrixId !=
|
directChatMatrixId !=
|
||||||
room.lastEvent?.senderId,
|
room.lastEvent?.senderId,
|
||||||
) ??
|
)
|
||||||
|
: null,
|
||||||
|
initialData:
|
||||||
|
room.lastEvent?.calcLocalizedBodyFallback(
|
||||||
|
MatrixLocals(L10n.of(context)!),
|
||||||
|
hideReply: true,
|
||||||
|
hideEdit: true,
|
||||||
|
plaintextBody: true,
|
||||||
|
removeMarkdown: true,
|
||||||
|
withSenderNamePrefix: !isDirectChat ||
|
||||||
|
directChatMatrixId !=
|
||||||
|
room.lastEvent?.senderId,
|
||||||
|
),
|
||||||
|
builder: (context, snapshot) => Text(
|
||||||
|
room.membership == Membership.invite
|
||||||
|
? isDirectChat
|
||||||
|
? L10n.of(context)!.invitePrivateChat
|
||||||
|
: L10n.of(context)!.inviteGroupChat
|
||||||
|
: snapshot.data ??
|
||||||
L10n.of(context)!.emptyChat,
|
L10n.of(context)!.emptyChat,
|
||||||
softWrap: false,
|
softWrap: false,
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
|
|
@ -256,6 +276,7 @@ class ChatListItem extends StatelessWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
AnimatedContainer(
|
AnimatedContainer(
|
||||||
duration: FluffyThemes.animationDuration,
|
duration: FluffyThemes.animationDuration,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue