mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-06 18:17:47 +08:00
refresh live msg if needed
Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
@@ -100,7 +100,9 @@ class LiveRoomController extends GetxController {
|
||||
// dm
|
||||
LiveDmInfoData? dmInfo;
|
||||
List<RichTextItem>? savedDanmaku;
|
||||
int builtLength = 0;
|
||||
RxList<dynamic> messages = <dynamic>[].obs;
|
||||
bool get shouldRefresh => builtLength != messages.length;
|
||||
late final Rx<SuperChatItem?> fsSC = Rx<SuperChatItem?>(null);
|
||||
late final RxList<SuperChatItem> superChatMsg = <SuperChatItem>[].obs;
|
||||
RxBool disableAutoScroll = false.obs;
|
||||
@@ -285,7 +287,17 @@ class LiveRoomController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
void jumpToBottom() {
|
||||
void handleJumpToBottom() {
|
||||
disableAutoScroll.value = false;
|
||||
if (shouldRefresh) {
|
||||
messages.refresh();
|
||||
WidgetsBinding.instance.addPostFrameCallback(_jumpToBottom);
|
||||
} else {
|
||||
_jumpToBottom();
|
||||
}
|
||||
}
|
||||
|
||||
void _jumpToBottom([_]) {
|
||||
if (scrollController.hasClients) {
|
||||
scrollController.jumpTo(scrollController.position.maxScrollExtent);
|
||||
}
|
||||
@@ -349,12 +361,21 @@ class LiveRoomController extends GetxController {
|
||||
disableAutoScroll.value = true;
|
||||
} else if (userScrollDirection == .reverse) {
|
||||
final pos = scrollController.position;
|
||||
if (pos.maxScrollExtent - pos.pixels <= 100) {
|
||||
if (pos.maxScrollExtent - pos.pixels <= 100 && disableAutoScroll.value) {
|
||||
disableAutoScroll.value = false;
|
||||
refreshMsgIfNeeded();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void refreshMsgIfNeeded() {
|
||||
if (shouldRefresh) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
messages.refresh();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
closeLiveMsg();
|
||||
|
||||
Reference in New Issue
Block a user