mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-12-24 14:32:37 +01:00
refactor: Stories header with futurebuilder
This commit is contained in:
parent
09a74bf3ee
commit
fd152baa28
@ -115,14 +115,11 @@ class StoriesHeader extends StatelessWidget {
|
||||
itemCount: stories.length,
|
||||
itemBuilder: (context, i) {
|
||||
final room = stories[i];
|
||||
return FutureBuilder<Profile>(
|
||||
future: room.getCreatorProfile(),
|
||||
builder: (context, snapshot) {
|
||||
final creator = room
|
||||
.unsafeGetUserFromMemoryOrFallback(room.creatorId ?? 'Unknown');
|
||||
final userId = room.creatorId;
|
||||
final displayname = snapshot.data?.displayName ??
|
||||
userId?.localpart ??
|
||||
'Unknown';
|
||||
final avatarUrl = snapshot.data?.avatarUrl;
|
||||
final displayname = creator.calcDisplayname();
|
||||
final avatarUrl = creator.avatarUrl;
|
||||
if (!displayname.toLowerCase().contains(filter.toLowerCase())) {
|
||||
return Container();
|
||||
}
|
||||
@ -140,7 +137,6 @@ class StoriesHeader extends StatelessWidget {
|
||||
onPressed: () => _goToStoryAction(context, room.id),
|
||||
onLongPressed: () => _contextualActions(context, room),
|
||||
);
|
||||
});
|
||||
},
|
||||
),
|
||||
);
|
||||
@ -148,9 +144,6 @@ class StoriesHeader extends StatelessWidget {
|
||||
}
|
||||
|
||||
extension on Room {
|
||||
Future<Profile> getCreatorProfile() =>
|
||||
client.getProfileFromUserId(getState(EventTypes.RoomCreate)!.senderId);
|
||||
|
||||
bool get hasPosts {
|
||||
if (membership == Membership.invite) return true;
|
||||
final lastEvent = this.lastEvent;
|
||||
|
Loading…
Reference in New Issue
Block a user