mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2025-03-30 04:27:01 +02:00
chore: Remove unnecessary stream subscriptions
This commit is contained in:
parent
5b96bfd83a
commit
874da53684
@ -88,77 +88,65 @@ class StoriesHeader extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final client = Matrix.of(context).client;
|
final client = Matrix.of(context).client;
|
||||||
return StreamBuilder(
|
if (Matrix.of(context).shareContent != null) {
|
||||||
stream: Matrix.of(context).onShareContentChanged.stream,
|
return ListTile(
|
||||||
builder: (context, _) => StreamBuilder<Object>(
|
leading: CircleAvatar(
|
||||||
stream: client.onSync.stream
|
radius: Avatar.defaultSize / 2,
|
||||||
.where((syncUpdate) => syncUpdate.hasRoomUpdate),
|
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||||
builder: (context, snapshot) {
|
foregroundColor: Theme.of(context).textTheme.bodyText1?.color,
|
||||||
if (Matrix.of(context).shareContent != null) {
|
child: const Icon(Icons.camera_alt_outlined),
|
||||||
return ListTile(
|
),
|
||||||
leading: CircleAvatar(
|
title: Text(L10n.of(context)!.addToStory),
|
||||||
radius: Avatar.defaultSize / 2,
|
onTap: () => _addToStoryAction(context),
|
||||||
backgroundColor: Theme.of(context).colorScheme.surface,
|
);
|
||||||
foregroundColor: Theme.of(context).textTheme.bodyText1?.color,
|
}
|
||||||
child: const Icon(Icons.camera_alt_outlined),
|
if (client.storiesRooms.isEmpty ||
|
||||||
),
|
!client.storiesRooms.any((room) =>
|
||||||
title: Text(L10n.of(context)!.addToStory),
|
room.displayname.toLowerCase().contains(filter.toLowerCase()))) {
|
||||||
onTap: () => _addToStoryAction(context),
|
return Container();
|
||||||
);
|
}
|
||||||
}
|
final ownStoryRoom = client.storiesRooms
|
||||||
if (client.storiesRooms.isEmpty ||
|
.firstWhereOrNull((r) => r.creatorId == client.userID);
|
||||||
!client.storiesRooms.any((room) => room.displayname
|
final stories = [
|
||||||
.toLowerCase()
|
if (ownStoryRoom != null) ownStoryRoom,
|
||||||
.contains(filter.toLowerCase()))) {
|
...client.storiesRooms..remove(ownStoryRoom),
|
||||||
return Container();
|
];
|
||||||
}
|
return SizedBox(
|
||||||
final ownStoryRoom = client.storiesRooms
|
height: 96,
|
||||||
.firstWhereOrNull((r) => r.creatorId == client.userID);
|
child: ListView.builder(
|
||||||
final stories = [
|
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||||
if (ownStoryRoom != null) ownStoryRoom,
|
scrollDirection: Axis.horizontal,
|
||||||
...client.storiesRooms..remove(ownStoryRoom),
|
itemCount: stories.length,
|
||||||
];
|
itemBuilder: (context, i) {
|
||||||
return SizedBox(
|
final room = stories[i];
|
||||||
height: 96,
|
return FutureBuilder<Profile>(
|
||||||
child: ListView.builder(
|
future: room.getCreatorProfile(),
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
builder: (context, snapshot) {
|
||||||
scrollDirection: Axis.horizontal,
|
final userId = room.creatorId;
|
||||||
itemCount: stories.length,
|
final displayname = snapshot.data?.displayName ??
|
||||||
itemBuilder: (context, i) {
|
userId?.localpart ??
|
||||||
final room = stories[i];
|
'Unknown';
|
||||||
return FutureBuilder<Profile>(
|
final avatarUrl = snapshot.data?.avatarUrl;
|
||||||
future: room.getCreatorProfile(),
|
if (!displayname.toLowerCase().contains(filter.toLowerCase())) {
|
||||||
builder: (context, snapshot) {
|
return Container();
|
||||||
final userId = room.creatorId;
|
}
|
||||||
final displayname = snapshot.data?.displayName ??
|
return _StoryButton(
|
||||||
userId?.localpart ??
|
profile: Profile(
|
||||||
'Unknown';
|
displayName: displayname,
|
||||||
final avatarUrl = snapshot.data?.avatarUrl;
|
avatarUrl: avatarUrl,
|
||||||
if (!displayname
|
userId: userId ?? 'Unknown',
|
||||||
.toLowerCase()
|
),
|
||||||
.contains(filter.toLowerCase())) {
|
heroTag: 'stories_${room.id}',
|
||||||
return Container();
|
hasPosts: room.hasPosts || room == ownStoryRoom,
|
||||||
}
|
showEditFab: userId == client.userID,
|
||||||
return _StoryButton(
|
unread: room.membership == Membership.invite ||
|
||||||
profile: Profile(
|
(room.hasNewMessages && room.hasPosts),
|
||||||
displayName: displayname,
|
onPressed: () => _goToStoryAction(context, room.id),
|
||||||
avatarUrl: avatarUrl,
|
onLongPressed: () => _contextualActions(context, room),
|
||||||
userId: userId ?? 'Unknown',
|
);
|
||||||
),
|
});
|
||||||
heroTag: 'stories_${room.id}',
|
},
|
||||||
hasPosts: room.hasPosts || room == ownStoryRoom,
|
),
|
||||||
showEditFab: userId == client.userID,
|
|
||||||
unread: room.membership == Membership.invite ||
|
|
||||||
(room.hasNewMessages && room.hasPosts),
|
|
||||||
onPressed: () => _goToStoryAction(context, room.id),
|
|
||||||
onLongPressed: () =>
|
|
||||||
_contextualActions(context, room),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user