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/material.dart';
|
||||
|
||||
|
|
@ -92,21 +95,28 @@ class ChatEventList extends StatelessWidget {
|
|||
|
||||
// Request history button or progress indicator:
|
||||
if (i == events.length + 1) {
|
||||
if (timeline.isRequestingHistory) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator.adaptive(strokeWidth: 2),
|
||||
);
|
||||
}
|
||||
if (timeline.canRequestHistory &&
|
||||
controller.activeThreadId == null) {
|
||||
if (controller.activeThreadId == null) {
|
||||
return Builder(
|
||||
builder: (context) {
|
||||
WidgetsBinding.instance
|
||||
.addPostFrameCallback(controller.requestHistory);
|
||||
final visibleIndex = timeline.events.lastIndexWhere(
|
||||
(event) =>
|
||||
!event.isCollapsedState && event.isVisibleInGui,
|
||||
);
|
||||
if (visibleIndex > timeline.events.length - 50) {
|
||||
WidgetsBinding.instance
|
||||
.addPostFrameCallback(controller.requestHistory);
|
||||
}
|
||||
return Center(
|
||||
child: IconButton(
|
||||
onPressed: controller.requestHistory,
|
||||
icon: const Icon(Icons.refresh_outlined),
|
||||
child: AnimatedSwitcher(
|
||||
duration: FluffyThemes.animationDuration,
|
||||
child: timeline.canRequestHistory
|
||||
? IconButton(
|
||||
onPressed: controller.requestHistory,
|
||||
icon: const Icon(Icons.refresh_outlined),
|
||||
)
|
||||
: const CircularProgressIndicator.adaptive(
|
||||
strokeWidth: 2,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue