mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-27 23:09:35 +01:00
fix: loading history
This commit is contained in:
parent
e13a732688
commit
a5e95539e3
@ -1609,7 +1609,7 @@
|
|||||||
"type": "text",
|
"type": "text",
|
||||||
"placeholders": {}
|
"placeholders": {}
|
||||||
},
|
},
|
||||||
"startYourFirstChat": "Start your first chat right now! 🙂\n- Tap on "+"\n- Enter the username of a friend\n- Have fun chatting",
|
"startYourFirstChat": "Start your first chat right now! 🙂\n- Tap on \"+\"\n- Enter the username of a friend\n- Have fun chatting",
|
||||||
"@startYourFirstChat": {
|
"@startYourFirstChat": {
|
||||||
"type": "text",
|
"type": "text",
|
||||||
"placeholders": {}
|
"placeholders": {}
|
||||||
|
@ -81,8 +81,6 @@ class _ChatState extends State<Chat> {
|
|||||||
|
|
||||||
bool get selectMode => selectedEvents.isNotEmpty;
|
bool get selectMode => selectedEvents.isNotEmpty;
|
||||||
|
|
||||||
bool _loadingHistory = false;
|
|
||||||
|
|
||||||
final int _loadHistoryCount = 100;
|
final int _loadHistoryCount = 100;
|
||||||
|
|
||||||
String inputText = '';
|
String inputText = '';
|
||||||
@ -93,8 +91,6 @@ class _ChatState extends State<Chat> {
|
|||||||
|
|
||||||
void requestHistory() async {
|
void requestHistory() async {
|
||||||
if (_canLoadMore) {
|
if (_canLoadMore) {
|
||||||
setState(() => _loadingHistory = true);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await timeline.requestHistory(historyCount: _loadHistoryCount);
|
await timeline.requestHistory(historyCount: _loadHistoryCount);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@ -102,11 +98,6 @@ class _ChatState extends State<Chat> {
|
|||||||
message: err.toLocalizedString(context))
|
message: err.toLocalizedString(context))
|
||||||
.show(context);
|
.show(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
// we do NOT setState() here as then the event order will be wrong.
|
|
||||||
// instead, we just set our variable to false, and rely on timeline update to set the
|
|
||||||
// new state, thus triggering a re-render, for us
|
|
||||||
_loadingHistory = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -633,7 +624,7 @@ class _ChatState extends State<Chat> {
|
|||||||
childrenDelegate: SliverChildBuilderDelegate(
|
childrenDelegate: SliverChildBuilderDelegate(
|
||||||
(BuildContext context, int i) {
|
(BuildContext context, int i) {
|
||||||
return i == filteredEvents.length + 1
|
return i == filteredEvents.length + 1
|
||||||
? _loadingHistory
|
? timeline.isRequestingHistory
|
||||||
? Container(
|
? Container(
|
||||||
height: 50,
|
height: 50,
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
|
@ -216,7 +216,7 @@ packages:
|
|||||||
description:
|
description:
|
||||||
path: "."
|
path: "."
|
||||||
ref: main
|
ref: main
|
||||||
resolved-ref: "0c89098b7a3231680d87cd79e1494d326a41574e"
|
resolved-ref: "4597ea344553e78a0817d7cdad16ac72079c8034"
|
||||||
url: "https://gitlab.com/famedly/famedlysdk.git"
|
url: "https://gitlab.com/famedly/famedlysdk.git"
|
||||||
source: git
|
source: git
|
||||||
version: "0.0.1"
|
version: "0.0.1"
|
||||||
|
Loading…
Reference in New Issue
Block a user