fix: Do not auto load history in rooms with collapsed state only
This commit is contained in:
parent
5d590c2c75
commit
5165b1b596
1 changed files with 22 additions and 12 deletions
|
|
@ -1,3 +1,6 @@
|
||||||
|
import 'dart:math';
|
||||||
|
|
||||||
|
import 'package:collection/collection.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
|
@ -92,21 +95,28 @@ class ChatEventList extends StatelessWidget {
|
||||||
|
|
||||||
// Request history button or progress indicator:
|
// Request history button or progress indicator:
|
||||||
if (i == events.length + 1) {
|
if (i == events.length + 1) {
|
||||||
if (timeline.isRequestingHistory) {
|
if (controller.activeThreadId == null) {
|
||||||
return const Center(
|
|
||||||
child: CircularProgressIndicator.adaptive(strokeWidth: 2),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (timeline.canRequestHistory &&
|
|
||||||
controller.activeThreadId == null) {
|
|
||||||
return Builder(
|
return Builder(
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
WidgetsBinding.instance
|
final visibleIndex = timeline.events.lastIndexWhere(
|
||||||
.addPostFrameCallback(controller.requestHistory);
|
(event) =>
|
||||||
|
!event.isCollapsedState && event.isVisibleInGui,
|
||||||
|
);
|
||||||
|
if (visibleIndex > timeline.events.length - 50) {
|
||||||
|
WidgetsBinding.instance
|
||||||
|
.addPostFrameCallback(controller.requestHistory);
|
||||||
|
}
|
||||||
return Center(
|
return Center(
|
||||||
child: IconButton(
|
child: AnimatedSwitcher(
|
||||||
onPressed: controller.requestHistory,
|
duration: FluffyThemes.animationDuration,
|
||||||
icon: const Icon(Icons.refresh_outlined),
|
child: timeline.canRequestHistory
|
||||||
|
? IconButton(
|
||||||
|
onPressed: controller.requestHistory,
|
||||||
|
icon: const Icon(Icons.refresh_outlined),
|
||||||
|
)
|
||||||
|
: const CircularProgressIndicator.adaptive(
|
||||||
|
strokeWidth: 2,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue