mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-20 02:59:26 +01:00
fix: Do not rebuild chat view twice on each message
This commit is contained in:
parent
587c4210f4
commit
fbe8ecaad5
@ -120,6 +120,12 @@ class ChatView extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool hasRoomStateUpdate(SyncUpdate syncUpdate) =>
|
||||||
|
syncUpdate.rooms?.leave?[controller.roomId]?.state?.isNotEmpty == true ||
|
||||||
|
syncUpdate.rooms?.invite?[controller.roomId]?.inviteState?.isNotEmpty ==
|
||||||
|
true ||
|
||||||
|
syncUpdate.rooms?.join?[controller.roomId]?.state?.isNotEmpty == true;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
controller.matrix ??= Matrix.of(context);
|
controller.matrix ??= Matrix.of(context);
|
||||||
@ -157,8 +163,12 @@ class ChatView extends StatelessWidget {
|
|||||||
onTapDown: controller.setReadMarker,
|
onTapDown: controller.setReadMarker,
|
||||||
behavior: HitTestBehavior.opaque,
|
behavior: HitTestBehavior.opaque,
|
||||||
child: StreamBuilder(
|
child: StreamBuilder(
|
||||||
stream: controller.room!.onUpdate.stream
|
stream: Matrix.of(context)
|
||||||
.rateLimit(const Duration(milliseconds: 250)),
|
.client
|
||||||
|
.onSync
|
||||||
|
.stream
|
||||||
|
.where(hasRoomStateUpdate)
|
||||||
|
.rateLimit(const Duration(seconds: 1)),
|
||||||
builder: (context, snapshot) => FutureBuilder<bool>(
|
builder: (context, snapshot) => FutureBuilder<bool>(
|
||||||
future: controller.getTimeline(),
|
future: controller.getTimeline(),
|
||||||
builder: (BuildContext context, snapshot) {
|
builder: (BuildContext context, snapshot) {
|
||||||
|
Loading…
Reference in New Issue
Block a user