コード例 #1
0
        private async Task <ErrorBase> Follow(UserFriend item, CancellationToken ct)
        {
            var hasFollowed = item.HasFollowed;
            var request     = new FollowModel(AppSettings.User.UserInfo, item.HasFollowed ? Models.Enums.FollowType.UnFollow : Models.Enums.FollowType.Follow, item.Author);
            var response    = await Api.Follow(request, ct);

            if (response.IsSuccess)
            {
                item.HasFollowed = !hasFollowed;
            }

            CashPresenterManager.Update(item);

            return(response.Error);
        }
コード例 #2
0
        public async Task <ErrorBase> TryFollow()
        {
            if (UserProfileResponse.FollowedChanging)
            {
                return(null);
            }

            UserProfileResponse.FollowedChanging = true;
            NotifySourceChanged(nameof(TryFollow), true);

            var error = await TryRunTask(Follow, OnDisposeCts.Token, UserProfileResponse);

            UserProfileResponse.FollowedChanging = false;
            CashPresenterManager.Update(UserProfileResponse);
            NotifySourceChanged(nameof(TryFollow), true);
            return(error);
        }