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;
|
GroupsList _groups;
|
||||||
ScrollWatcher _scrollController;
|
ScrollWatcher _scrollController;
|
||||||
ErrorLevel _error = ErrorLevel.NONE;
|
ErrorLevel _error = ErrorLevel.NONE;
|
||||||
|
bool _loading = false;
|
||||||
|
|
||||||
set error(ErrorLevel err) => setState(() => _error = err);
|
set error(ErrorLevel err) => setState(() => _error = err);
|
||||||
|
|
||||||
@ -68,11 +69,19 @@ class _PostsListWidgetState extends State<PostsListWidget> {
|
|||||||
_loadPostsList();
|
_loadPostsList();
|
||||||
}
|
}
|
||||||
|
|
||||||
void _loadError() =>
|
void _loadError() {
|
||||||
error = _list == null ? ErrorLevel.MAJOR : ErrorLevel.MINOR;
|
error = _list == null ? ErrorLevel.MAJOR : ErrorLevel.MINOR;
|
||||||
|
_loading = false;
|
||||||
|
}
|
||||||
|
|
||||||
/// Load the list of posts
|
/// Load the list of posts
|
||||||
Future<void> _loadPostsList({bool getOlder = false}) async {
|
Future<void> _loadPostsList({bool getOlder = false}) async {
|
||||||
|
|
||||||
|
if(_loading)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_loading = true;
|
||||||
|
|
||||||
final list = !getOlder
|
final list = !getOlder
|
||||||
? await widget.getPostsList()
|
? await widget.getPostsList()
|
||||||
: await widget.getOlder(_list.oldestID);
|
: await widget.getOlder(_list.oldestID);
|
||||||
@ -98,6 +107,8 @@ class _PostsListWidgetState extends State<PostsListWidget> {
|
|||||||
_groups.addAll(groups);
|
_groups.addAll(groups);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
_loading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildErrorCard() {
|
Widget _buildErrorCard() {
|
||||||
|
Loading…
Reference in New Issue
Block a user