fix: loading history

This commit is contained in:
Christian Pauly 2021-01-16 16:11:50 +01:00
parent e13a732688
commit a5e95539e3
3 changed files with 3 additions and 12 deletions

View File

@ -1609,7 +1609,7 @@
"type": "text",
"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": {
"type": "text",
"placeholders": {}

View File

@ -81,8 +81,6 @@ class _ChatState extends State<Chat> {
bool get selectMode => selectedEvents.isNotEmpty;
bool _loadingHistory = false;
final int _loadHistoryCount = 100;
String inputText = '';
@ -93,8 +91,6 @@ class _ChatState extends State<Chat> {
void requestHistory() async {
if (_canLoadMore) {
setState(() => _loadingHistory = true);
try {
await timeline.requestHistory(historyCount: _loadHistoryCount);
} catch (err) {
@ -102,11 +98,6 @@ class _ChatState extends State<Chat> {
message: err.toLocalizedString(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(
(BuildContext context, int i) {
return i == filteredEvents.length + 1
? _loadingHistory
? timeline.isRequestingHistory
? Container(
height: 50,
alignment: Alignment.center,

View File

@ -216,7 +216,7 @@ packages:
description:
path: "."
ref: main
resolved-ref: "0c89098b7a3231680d87cd79e1494d326a41574e"
resolved-ref: "4597ea344553e78a0817d7cdad16ac72079c8034"
url: "https://gitlab.com/famedly/famedlysdk.git"
source: git
version: "0.0.1"