fix auto scroll down sometimes not triggering
This commit is contained in:
parent
a87c9dc678
commit
e63e5a8c08
1 changed files with 11 additions and 8 deletions
|
|
@ -82,21 +82,24 @@ class RoomChat extends HookConsumerWidget {
|
||||||
final topEventBeforeLoad = useState<String?>(null);
|
final topEventBeforeLoad = useState<String?>(null);
|
||||||
|
|
||||||
Future<void> loadOlder() async {
|
Future<void> loadOlder() async {
|
||||||
if (controllerData
|
if (controllerData case AsyncData(:final value)) {
|
||||||
case AsyncData(:final value) || AsyncLoading(:final value?)) {
|
|
||||||
topEventBeforeLoad.value = value.firstOrNull?.eventId;
|
topEventBeforeLoad.value = value.firstOrNull?.eventId;
|
||||||
await notifier.loadOlder();
|
await notifier.loadOlder();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() {
|
useEffect(() {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
ref
|
||||||
|
.read(controllerProvider.future)
|
||||||
|
.then(
|
||||||
|
(_) => WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
if (scrollController.hasClients) {
|
if (scrollController.hasClients) {
|
||||||
scrollController.jumpTo(
|
scrollController.jumpTo(
|
||||||
scrollController.position.maxScrollExtent - .000001,
|
scrollController.position.maxScrollExtent - .000001,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}, [scrollController.hasClients]);
|
}, [scrollController.hasClients]);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue