Skip to content

Commit

Permalink
🐛 Fix status changes too slow with request makes it seems not changed…
Browse files Browse the repository at this point in the history
… successfully.
  • Loading branch information
AlexV525 committed Feb 19, 2020
1 parent 43aa4f9 commit 54e6676
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
1 change: 1 addition & 0 deletions lib/api/user_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ class UserAPI {
await NetUtils.postWithCookieAndHeaderSet(API.userFollowAdd, data: {'fid': uid, 'tagid': 0});
} catch (e) {
debugPrint('Failed when folloe: $e');
showCenterErrorToast('关注失败');
}
}

Expand Down
15 changes: 4 additions & 11 deletions lib/pages/user/user_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -192,19 +192,12 @@ class _UserPageState extends State<UserPage>
);
} else {
if (_user.isFollowing) {
UserAPI.unFollow(widget.uid).then((response) {
_user.isFollowing = false;
if (mounted) setState(() {});
});
UserAPI.unFollow(widget.uid);
} else {
UserAPI.follow(widget.uid).then((response) {
_user.isFollowing = true;
if (mounted) setState(() {});
}).catchError((e) {
debugPrint('Failed when follow: $e');
showCenterErrorToast('关注失败');
});
UserAPI.follow(widget.uid);
}
_user.isFollowing = !_user.isFollowing;
if (mounted) setState(() {});
}
},
color: isSelf
Expand Down

0 comments on commit 54e6676

Please sign in to comment.