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