mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-16 00:49:31 +01:00
fix: User pills
This commit is contained in:
parent
b00111381a
commit
3942de3222
@ -422,6 +422,11 @@ class RoomPillExtension extends HtmlExtension {
|
||||
return userId != null;
|
||||
}
|
||||
|
||||
static final _cachedUsers = <String, User?>{};
|
||||
|
||||
Future<User?> _fetchUser(String matrixId) async =>
|
||||
_cachedUsers[room.id + matrixId] ??= await room.requestUser(matrixId);
|
||||
|
||||
@override
|
||||
InlineSpan build(
|
||||
ExtensionContext context,
|
||||
@ -433,15 +438,19 @@ class RoomPillExtension extends HtmlExtension {
|
||||
return TextSpan(text: context.innerHtml);
|
||||
}
|
||||
if (matrixId.sigil == '@') {
|
||||
final user = room.unsafeGetUserFromMemoryOrFallback(matrixId);
|
||||
return WidgetSpan(
|
||||
child: MatrixPill(
|
||||
child: FutureBuilder<User?>(
|
||||
future: _fetchUser(matrixId),
|
||||
builder: (context, snapshot) => MatrixPill(
|
||||
key: Key('user_pill_$matrixId'),
|
||||
name: user.calcDisplayname(),
|
||||
avatar: user.avatarUrl,
|
||||
name: _cachedUsers[room.id + matrixId]?.calcDisplayname() ??
|
||||
matrixId.localpart ??
|
||||
matrixId,
|
||||
avatar: _cachedUsers[room.id + matrixId]?.avatarUrl,
|
||||
uri: href,
|
||||
outerContext: this.context,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
if (matrixId.sigil == '#' || matrixId.sigil == '!') {
|
||||
|
@ -1059,10 +1059,10 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: matrix
|
||||
sha256: "2b07709bce975d2be4dc4cd3cc1196fcd6c0397d4e250b42a498e35523fc28f3"
|
||||
sha256: a1c336a1f1d8f914cd8ec1adb4cab4f062e36ccabcc1a849389c85031a73f9d2
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.20.1"
|
||||
version: "0.20.4"
|
||||
matrix_api_lite:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -62,7 +62,7 @@ dependencies:
|
||||
keyboard_shortcuts: ^0.1.4
|
||||
latlong2: ^0.8.1
|
||||
linkify: ^5.0.0
|
||||
matrix: ^0.20.1
|
||||
matrix: ^0.20.4
|
||||
matrix_homeserver_recommendations: ^0.3.0
|
||||
native_imaging: ^0.1.0
|
||||
package_info_plus: ^4.0.0
|
||||
|
Loading…
Reference in New Issue
Block a user