1
0
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:
Pierre HUBERT 2019-06-15 16:29:07 +02:00
parent 48f2db98b0
commit a29af0fe01

View File

@ -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() =>
error = _list == null ? ErrorLevel.MAJOR : ErrorLevel.MINOR;
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() {