mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 12:59:21 +00:00
Avoid posts to load twice
This commit is contained in:
parent
48f2db98b0
commit
a29af0fe01
@ -52,6 +52,7 @@ class _PostsListWidgetState extends State<PostsListWidget> {
|
||||
GroupsList _groups;
|
||||
ScrollWatcher _scrollController;
|
||||
ErrorLevel _error = ErrorLevel.NONE;
|
||||
bool _loading = false;
|
||||
|
||||
set error(ErrorLevel err) => setState(() => _error = err);
|
||||
|
||||
@ -68,11 +69,19 @@ class _PostsListWidgetState extends State<PostsListWidget> {
|
||||
_loadPostsList();
|
||||
}
|
||||
|
||||
void _loadError() =>
|
||||
void _loadError() {
|
||||
error = _list == null ? ErrorLevel.MAJOR : ErrorLevel.MINOR;
|
||||
_loading = false;
|
||||
}
|
||||
|
||||
/// Load the list of posts
|
||||
Future<void> _loadPostsList({bool getOlder = false}) async {
|
||||
|
||||
if(_loading)
|
||||
return;
|
||||
|
||||
_loading = true;
|
||||
|
||||
final list = !getOlder
|
||||
? await widget.getPostsList()
|
||||
: await widget.getOlder(_list.oldestID);
|
||||
@ -98,6 +107,8 @@ class _PostsListWidgetState extends State<PostsListWidget> {
|
||||
_groups.addAll(groups);
|
||||
}
|
||||
});
|
||||
|
||||
_loading = false;
|
||||
}
|
||||
|
||||
Widget _buildErrorCard() {
|
||||
|
Loading…
Reference in New Issue
Block a user