refactor: Use onRoomState stream instead of room.onUpdate to not update on messages but state changes only

This commit is contained in:
krille-chan 2024-05-19 07:52:18 +02:00
parent 06b2e6c14f
commit ff54610e5b
No known key found for this signature in database
6 changed files with 12 additions and 6 deletions

View file

@ -150,7 +150,8 @@ class ChatView extends StatelessWidget {
}
},
child: StreamBuilder(
stream: controller.room.onUpdate.stream
stream: controller.room.client.onRoomState.stream
.where((update) => update.roomId == controller.room.id)
.rateLimit(const Duration(seconds: 1)),
builder: (context, snapshot) => FutureBuilder(
future: controller.loadTimelineFuture,

View file

@ -22,7 +22,8 @@ class ChatAccessSettingsPageView extends StatelessWidget {
),
body: MaxWidthBody(
child: StreamBuilder<Object>(
stream: room.onUpdate.stream,
stream: room.client.onRoomState.stream
.where((update) => update.roomId == controller.room.id),
builder: (context, snapshot) {
final canonicalAlias = room.canonicalAlias;
final altAliases = room

View file

@ -36,7 +36,8 @@ class ChatDetailsView extends StatelessWidget {
}
return StreamBuilder(
stream: room.onUpdate.stream,
stream: room.client.onRoomState.stream
.where((update) => update.roomId == room.id),
builder: (context, snapshot) {
var members = room.getParticipants().toList()
..sort((b, a) => a.powerLevel.compareTo(b.powerLevel));

View file

@ -82,7 +82,8 @@ class ChatEncryptionSettingsView extends StatelessWidget {
),
),
StreamBuilder(
stream: room.onUpdate.stream,
stream: room.client.onRoomState.stream
.where((update) => update.roomId == controller.room.id),
builder: (context, snapshot) =>
FutureBuilder<List<DeviceKeys>>(
future: room.getUserDeviceKeys(),

View file

@ -64,7 +64,8 @@ class InvitationSelectionView extends StatelessWidget {
),
),
StreamBuilder<Object>(
stream: room.onUpdate.stream,
stream: room.client.onRoomState.stream
.where((update) => update.roomId == room.id),
builder: (context, snapshot) {
final participants =
room.getParticipants().map((user) => user.id).toSet();

View file

@ -21,7 +21,8 @@ class MultipleEmotesSettingsView extends StatelessWidget {
title: Text(L10n.of(context)!.emotePacks),
),
body: StreamBuilder(
stream: room.onUpdate.stream,
stream: room.client.onRoomState.stream
.where((update) => update.roomId == room.id),
builder: (context, snapshot) {
final packStateEvents = room.states['im.ponies.room_emotes'];
// we need to manually convert the map using Map.of, otherwise assigning null will throw a type error.