mirror of
https://github.com/krille-chan/fluffychat
synced 2024-08-10 16:33:47 +00:00
refactor: Use onRoomState stream instead of room.onUpdate to not update on messages but state changes only
This commit is contained in:
parent
06b2e6c14f
commit
ff54610e5b
6 changed files with 12 additions and 6 deletions
|
@ -150,7 +150,8 @@ class ChatView extends StatelessWidget {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: StreamBuilder(
|
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)),
|
.rateLimit(const Duration(seconds: 1)),
|
||||||
builder: (context, snapshot) => FutureBuilder(
|
builder: (context, snapshot) => FutureBuilder(
|
||||||
future: controller.loadTimelineFuture,
|
future: controller.loadTimelineFuture,
|
||||||
|
|
|
@ -22,7 +22,8 @@ class ChatAccessSettingsPageView extends StatelessWidget {
|
||||||
),
|
),
|
||||||
body: MaxWidthBody(
|
body: MaxWidthBody(
|
||||||
child: StreamBuilder<Object>(
|
child: StreamBuilder<Object>(
|
||||||
stream: room.onUpdate.stream,
|
stream: room.client.onRoomState.stream
|
||||||
|
.where((update) => update.roomId == controller.room.id),
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
final canonicalAlias = room.canonicalAlias;
|
final canonicalAlias = room.canonicalAlias;
|
||||||
final altAliases = room
|
final altAliases = room
|
||||||
|
|
|
@ -36,7 +36,8 @@ class ChatDetailsView extends StatelessWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
return StreamBuilder(
|
return StreamBuilder(
|
||||||
stream: room.onUpdate.stream,
|
stream: room.client.onRoomState.stream
|
||||||
|
.where((update) => update.roomId == room.id),
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
var members = room.getParticipants().toList()
|
var members = room.getParticipants().toList()
|
||||||
..sort((b, a) => a.powerLevel.compareTo(b.powerLevel));
|
..sort((b, a) => a.powerLevel.compareTo(b.powerLevel));
|
||||||
|
|
|
@ -82,7 +82,8 @@ class ChatEncryptionSettingsView extends StatelessWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
StreamBuilder(
|
StreamBuilder(
|
||||||
stream: room.onUpdate.stream,
|
stream: room.client.onRoomState.stream
|
||||||
|
.where((update) => update.roomId == controller.room.id),
|
||||||
builder: (context, snapshot) =>
|
builder: (context, snapshot) =>
|
||||||
FutureBuilder<List<DeviceKeys>>(
|
FutureBuilder<List<DeviceKeys>>(
|
||||||
future: room.getUserDeviceKeys(),
|
future: room.getUserDeviceKeys(),
|
||||||
|
|
|
@ -64,7 +64,8 @@ class InvitationSelectionView extends StatelessWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
StreamBuilder<Object>(
|
StreamBuilder<Object>(
|
||||||
stream: room.onUpdate.stream,
|
stream: room.client.onRoomState.stream
|
||||||
|
.where((update) => update.roomId == room.id),
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
final participants =
|
final participants =
|
||||||
room.getParticipants().map((user) => user.id).toSet();
|
room.getParticipants().map((user) => user.id).toSet();
|
||||||
|
|
|
@ -21,7 +21,8 @@ class MultipleEmotesSettingsView extends StatelessWidget {
|
||||||
title: Text(L10n.of(context)!.emotePacks),
|
title: Text(L10n.of(context)!.emotePacks),
|
||||||
),
|
),
|
||||||
body: StreamBuilder(
|
body: StreamBuilder(
|
||||||
stream: room.onUpdate.stream,
|
stream: room.client.onRoomState.stream
|
||||||
|
.where((update) => update.roomId == room.id),
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
final packStateEvents = room.states['im.ponies.room_emotes'];
|
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.
|
// we need to manually convert the map using Map.of, otherwise assigning null will throw a type error.
|
||||||
|
|
Loading…
Reference in a new issue