mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 12:59:21 +00:00
Can load older posts on user page
This commit is contained in:
parent
c7502e6a04
commit
302e5f22ce
@ -67,10 +67,9 @@ class PostsHelper {
|
||||
|
||||
/// Get the list of posts of a user
|
||||
Future<PostsList> getUserPosts(int userID, {int from = 0}) async {
|
||||
final response = await APIRequest(
|
||||
uri: "posts/get_user",
|
||||
needLogin: true,
|
||||
args: {"userID": userID.toString(), "startFrom": from.toString()})
|
||||
final response = await (APIRequest(uri: "posts/get_user", needLogin: true)
|
||||
..addInt("userID", userID)
|
||||
..addInt("startFrom", from == 0 ? 0 : from - 1))
|
||||
.exec();
|
||||
|
||||
if (response.code != 200) return null;
|
||||
|
@ -7,6 +7,7 @@ import 'package:comunic/ui/routes/user_access_denied_route.dart';
|
||||
import 'package:comunic/ui/widgets/network_image_widget.dart';
|
||||
import 'package:comunic/ui/widgets/post_create_form_widget.dart';
|
||||
import 'package:comunic/ui/widgets/posts_list_widget.dart';
|
||||
import 'package:comunic/ui/widgets/scroll_watcher.dart';
|
||||
import 'package:comunic/utils/conversations_utils.dart';
|
||||
import 'package:comunic/utils/intl_utils.dart';
|
||||
import 'package:comunic/utils/ui_utils.dart';
|
||||
@ -43,8 +44,19 @@ class _UserPageRouteState extends State<UserPageRoute> {
|
||||
GlobalKey<RefreshIndicatorState> _refreshIndicatorKey =
|
||||
GlobalKey<RefreshIndicatorState>();
|
||||
|
||||
// Scroll detection (to load more user posts automatically)
|
||||
final _postListKey = GlobalKey<PostsListWidgetState>();
|
||||
ScrollWatcher _scrollWatcher;
|
||||
|
||||
_setStatus(_PageStatus s) => setState(() => _status = s);
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_scrollWatcher = ScrollWatcher(
|
||||
onReachBottom: () => _postListKey.currentState.reachedPostsBottom());
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
@ -88,6 +100,7 @@ class _UserPageRouteState extends State<UserPageRoute> {
|
||||
child: CustomScrollView(
|
||||
slivers: <Widget>[_buildHeader(), _buildBody()],
|
||||
physics: AlwaysScrollableScrollPhysics(),
|
||||
controller: _scrollWatcher,
|
||||
),
|
||||
onRefresh: _getUserInfo,
|
||||
),
|
||||
@ -192,7 +205,10 @@ class _UserPageRouteState extends State<UserPageRoute> {
|
||||
|
||||
// Posts list
|
||||
PostsListWidget(
|
||||
key: _postListKey,
|
||||
getPostsList: () => _postsHelper.getUserPosts(widget.userID),
|
||||
getOlder: (from) =>
|
||||
_postsHelper.getUserPosts(widget.userID, from: from),
|
||||
showPostsTarget: false,
|
||||
buildListView: false,
|
||||
),
|
||||
|
Loading…
Reference in New Issue
Block a user