Beispiel #1
0
 public static object fetchFollowArticles(int pageNumber)
 {
     return(new ThunkAction <AppState>((dispatcher, getState) => {
         return ArticleApi.FetchFollowArticles(pageNumber)
         .Then(followArticlesResponse => {
             dispatcher.dispatch(new UserMapAction {
                 userMap = followArticlesResponse.userMap
             });
             dispatcher.dispatch(new TeamMapAction {
                 teamMap = followArticlesResponse.teamMap
             });
             dispatcher.dispatch(new FollowMapAction {
                 followMap = followArticlesResponse.followMap
             });
             dispatcher.dispatch(new LikeMapAction {
                 likeMap = followArticlesResponse.likeMap
             });
             dispatcher.dispatch(new FetchFollowArticleSuccessAction {
                 pageNumber = pageNumber,
                 projects = followArticlesResponse.projects,
                 projectHasMore = followArticlesResponse.projectHasMore,
                 hottests = followArticlesResponse.hottests,
                 hottestHasMore = followArticlesResponse.hottestHasMore
             });
         })
         .Catch(error => {
             dispatcher.dispatch(new FetchFollowArticleFailureAction());
             Debug.Log(error);
         });
     }));
 }
 public static object fetchArticles(int offset)
 {
     return(new ThunkAction <AppState>((dispatcher, getState) => {
         return ArticleApi.FetchArticles(offset)
         .Then(articlesResponse => {
             var articleList = new List <Article>();
             articlesResponse.hottests.ForEach(item => {
                 if (articlesResponse.projectMap.ContainsKey(item.itemId))
                 {
                     var article = articlesResponse.projectMap[item.itemId];
                     articleList.Add(article);
                 }
             });
             dispatcher.dispatch(new UserMapAction {
                 userMap = articlesResponse.userMap
             });
             dispatcher.dispatch(new TeamMapAction {
                 teamMap = articlesResponse.teamMap
             });
             dispatcher.dispatch(new FetchArticleSuccessAction {
                 offset = offset,
                 hottestHasMore = articlesResponse.hottestHasMore,
                 articleList = articleList
             });
         })
         .Catch(error => {
             dispatcher.dispatch(new FetchArticleFailureAction());
             Debug.Log(error);
         });
     }));
 }
Beispiel #3
0
 public static object sendComment(string articleId, string channelId, string content, string nonce,
                                  string parentMessageId)
 {
     return(new ThunkAction <AppState>((dispatcher, getState) => {
         return ArticleApi.SendComment(channelId, content, nonce, parentMessageId)
         .Then(message => {
             CustomDialogUtils.hiddenCustomDialog();
             if (message.deleted)
             {
                 if (parentMessageId.isNotEmpty())
                 {
                     CustomDialogUtils.showToast("此条评论已被删除", iconData: Icons.sentiment_dissatisfied);
                 }
             }
             else
             {
                 CustomDialogUtils.showToast("发送成功", iconData: Icons.sentiment_satisfied);
             }
             dispatcher.dispatch(new SendCommentSuccessAction {
                 message = message,
                 articleId = articleId,
                 channelId = channelId,
                 parentMessageId = parentMessageId
             });
         })
         .Catch(error => {
             CustomDialogUtils.hiddenCustomDialog();
             CustomDialogUtils.showToast("发送失败", iconData: Icons.sentiment_dissatisfied);
         });
     }));
 }
Beispiel #4
0
        public async Task <VoteResult> VoteUpAsync(String access, Int32 articleId)
        {
            var api    = new ArticleApi();
            var result = await api.VoteUpAsync(access, articleId);

            return(result);
        }
Beispiel #5
0
        public async Task <VoteResult> CancelVoteDownAsync(String access, Int32 articleId, String loginId)
        {
            var api    = new ArticleApi();
            var result = await api.CancelVoteDownAsync(access, articleId, loginId);

            return(result);
        }
Beispiel #6
0
        public static object favoriteArticle(string articleId, List <string> tagIds)
        {
            if (HttpManager.isNetWorkError())
            {
                CustomDialogUtils.showToast("请检查网络", iconData: Icons.sentiment_dissatisfied);
                return(null);
            }

            CustomDialogUtils.showCustomDialog(
                child: new CustomLoadingDialog(
                    message: "操作中"
                    )
                );
            return(new ThunkAction <AppState>((dispatcher, getState) => {
                return ArticleApi.FavoriteArticle(articleId: articleId, tagIds: tagIds)
                .Then(favoriteArticleResponse => {
                    CustomDialogUtils.hiddenCustomDialog();
                    CustomDialogUtils.showToast("操作成功", iconData: Icons.sentiment_satisfied);
                    dispatcher.dispatch(new FavoriteArticleSuccessAction {
                        favorites = favoriteArticleResponse,
                        articleId = articleId
                    });
                    AnalyticsManager.AnalyticsFavoriteArticle(articleId: articleId, favoriteTagIds: tagIds);
                })
                .Catch(error => {
                    CustomDialogUtils.hiddenCustomDialog();
                    Debuger.LogError(message: error);
                });
            }));
        }
Beispiel #7
0
        public static object unFavoriteArticle(string articleId, string favoriteId)
        {
            if (HttpManager.isNetWorkError())
            {
                CustomDialogUtils.showToast("请检查网络", iconData: Icons.sentiment_dissatisfied);
                return(null);
            }

            CustomDialogUtils.showCustomDialog(
                child: new CustomLoadingDialog(
                    message: "取消收藏中"
                    )
                );
            return(new ThunkAction <AppState>((dispatcher, getState) => {
                return ArticleApi.UnFavoriteArticle(favoriteId: favoriteId)
                .Then(unFavoriteArticleResponse => {
                    CustomDialogUtils.hiddenCustomDialog();
                    CustomDialogUtils.showToast("取消收藏成功", iconData: Icons.sentiment_satisfied);
                    dispatcher.dispatch(new UnFavoriteArticleSuccessAction {
                        favorite = unFavoriteArticleResponse,
                        articleId = articleId
                    });
                    AnalyticsManager.AnalyticsUnFavoriteArticle(favoriteId: favoriteId);
                })
                .Catch(error => {
                    CustomDialogUtils.hiddenCustomDialog();
                    Debuger.LogError(message: error);
                });
            }));
        }
        public Result <Articles> GetByIdApi(int id)
        {
            ArticleApi  item = HurriyetApi.SingleApi(id);
            CategoryRep cr   = new CategoryRep();
            Articles    a    = new Articles();

            a.Title       = item.Title;
            a.Description = item.Description;
            a.NewsDate    = item.ModifiedDate;
            a.ArticleId   = item.Id;
            a.Text        = item.Text;
            if (item.Files != null)
            {
                foreach (var photo in item.Files)
                {
                    a.Photo = photo.FileUrl;
                    break;
                }
            }
            if (item.Path != null)
            {
                foreach (var cat in cr.List().ProccessResult)
                {
                    if (item.Path.ToLower().Contains(cat.CategoryName.Replace("ü", "u").ToLower()))
                    {
                        a.CategoryId = cat.ID;
                    }
                }
            }

            return(result.GetT(a));
        }
Beispiel #9
0
        private static ClassifierResult CreateClassifierResult(JObject result)
        {
            ClassifierResult classifierResult = Newtonsoft.Json.JsonConvert.DeserializeObject <ClassifierResult>(result.ToString());

            switch (classifierResult.Type)
            {
            case PageType.Article:
                classifierResult.PageResult = ArticleApi.CreateArticle(result);
                break;

            case PageType.FrontPage:
                classifierResult.PageResult = FrontPageApi.CreateFrontPage(result);
                break;

            case PageType.Image:
                classifierResult.PageResult = ImageApi.CreateImages(result);
                break;

            case PageType.Product:
                classifierResult.PageResult = ProductApi.CreateProduct(result);
                break;
            }

            return(classifierResult);
        }
Beispiel #10
0
        public async Task <CommentsResult> GetCommentsAsync(String accessToken, Int32 articleId, String request,
                                                            Boolean autoCache = false)
        {
            var api    = new ArticleApi();
            var result = await api.GetCommentsAsync(accessToken, articleId, request, autoCache);

            return(result);
        }
Beispiel #11
0
        public async Task <ArticleResult> GetDetailAsync(String accessToken, Int32 articleId,
                                                         Boolean autoCache = false)
        {
            var api    = new ArticleApi();
            var result = await api.GetDetailAsync(accessToken, articleId, autoCache);

            return(result);
        }
Beispiel #12
0
        public static object fetchArticleComments(string channelId, string currOldestMessageId = "")
        {
            return(new ThunkAction <AppState>((dispatcher, getState) => {
                return ArticleApi.FetchArticleComments(channelId: channelId, currOldestMessageId: currOldestMessageId)
                .Then(responseComments => {
                    var itemIds = new List <string>();
                    var messageItems = new Dictionary <string, Message>();
                    var userMap = new Dictionary <string, User>();
                    responseComments.items.ForEach(message => {
                        itemIds.Add(item: message.id);
                        messageItems[key: message.id] = message;
                        if (userMap.ContainsKey(key: message.author.id))
                        {
                            userMap[key: message.author.id] = message.author;
                        }
                        else
                        {
                            userMap.Add(key: message.author.id, value: message.author);
                        }
                    });
                    responseComments.parents.ForEach(message => {
                        if (messageItems.ContainsKey(key: message.id))
                        {
                            messageItems[key: message.id] = message;
                        }
                        else
                        {
                            messageItems.Add(key: message.id, value: message);
                        }

                        if (userMap.ContainsKey(key: message.author.id))
                        {
                            userMap[key: message.author.id] = message.author;
                        }
                        else
                        {
                            userMap.Add(key: message.author.id, value: message.author);
                        }
                    });
                    dispatcher.dispatch(new UserMapAction {
                        userMap = userMap
                    });
                    dispatcher.dispatch(new UserLicenseMapAction
                    {
                        userLicenseMap = responseComments.userLicenseMap
                    });
                    dispatcher.dispatch(new FetchArticleCommentsSuccessAction {
                        channelId = channelId,
                        itemIds = itemIds,
                        messageItems = messageItems,
                        isRefreshList = false,
                        hasMore = responseComments.hasMore,
                        currOldestMessageId = responseComments.currOldestMessageId
                    });
                })
                .Catch(onRejected: Debuger.LogError);
            }));
        }
        //id e göre haberin çekilme islemi.. haberin textini alabilmek icin yaptım.
        public ArticleApi SingleApi(int id)
        {
            HurriyetConf.ApiKey = "d500daf3de1d4d499521850f317d19e8";
            ArticleApi ap = new ArticleApi();
            string     json;

            json = Hurriyet.SingleArticle(id.ToString()).ToString();
            ap   = JsonConvert.DeserializeObject <ArticleApi>(json);
            return(ap);
        }
Beispiel #14
0
        public static object FetchArticleDetail(string articleId)
        {
            return(new ThunkAction <AppState>((dispatcher, getState) => {
                return ArticleApi.FetchArticleDetail(articleId)
                .Then(articleDetailResponse => {
                    if (articleDetailResponse.project.comments.items.Count > 0)
                    {
                        var itemIds = new List <string>();
                        var messageItems = new Dictionary <string, Message>();
                        var userMap = new Dictionary <string, User>();
                        articleDetailResponse.project.comments.items.ForEach(message => {
                            itemIds.Add(message.id);
                            messageItems[message.id] = message;
                            if (userMap.ContainsKey(message.author.id))
                            {
                                userMap[message.author.id] = message.author;
                            }
                            else
                            {
                                userMap.Add(message.author.id, message.author);
                            }
                        });
                        dispatcher.dispatch(new UserMapAction {
                            userMap = userMap
                        });
                        dispatcher.dispatch(new FetchArticleCommentsSuccessAction {
                            channelId = articleDetailResponse.project.channelId,
                            itemIds = itemIds,
                            messageItems = messageItems,
                            isRefreshList = true,
                            hasMore = articleDetailResponse.project.comments.hasMore,
                            currOldestMessageId = articleDetailResponse.project.comments.currOldestMessageId
                        });
                    }

                    dispatcher.dispatch(new UserMapAction {
                        userMap = articleDetailResponse.project.userMap
                    });
                    dispatcher.dispatch(new TeamMapAction {
                        teamMap = articleDetailResponse.project.teamMap
                    });
                    dispatcher.dispatch(new FetchArticleDetailSuccessAction {
                        articleDetail = articleDetailResponse.project
                    });
                    dispatcher.dispatch(new SaveArticleHistoryAction {
                        article = articleDetailResponse.project.projectData
                    });
                })
                .Catch(error => {
//                        dispatcher.dispatch(new FetchArticleDetailFailureAction());
                    Debug.Log(error);
                });
            }));
        }
Beispiel #15
0
 public static object likeArticle(string articleId)
 {
     return(new ThunkAction <AppState>((dispatcher, getState) => {
         return ArticleApi.LikeArticle(articleId)
         .Then(() => {
             CustomDialogUtils.showToast("点赞成功", Icons.sentiment_satisfied);
             dispatcher.dispatch(new LikeArticleSuccessAction {
                 articleId = articleId
             });
         })
         .Catch(_ => CustomDialogUtils.showToast("点赞失败", Icons.sentiment_dissatisfied));
     }));
 }
Beispiel #16
0
 public static object likeComment(string messageId)
 {
     return(new ThunkAction <AppState>((dispatcher, getState) => {
         return ArticleApi.LikeComment(messageId)
         .Then(message => {
             CustomDialogUtils.showToast("点赞成功", Icons.sentiment_satisfied);
             dispatcher.dispatch(new LikeCommentSuccessAction {
                 message = message
             });
         })
         .Catch(error => {
             CustomDialogUtils.showToast("点赞失败", Icons.sentiment_dissatisfied);
             dispatcher.dispatch(new LikeCommentFailureAction());
         });
     }));
 }
Beispiel #17
0
 public static object removeLikeComment(string messageId)
 {
     return(new ThunkAction <AppState>((dispatcher, getState) => {
         return ArticleApi.RemoveLikeComment(messageId)
         .Then(message => {
             CustomDialogUtils.showToast("已取消点赞", Icons.sentiment_satisfied);
             dispatcher.dispatch(new RemoveLikeCommentSuccessAction {
                 message = message
             });
         })
         .Catch(error => {
             CustomDialogUtils.showToast("取消点赞失败", Icons.sentiment_dissatisfied);
             Debug.Log(error);
         });
     }));
 }
Beispiel #18
0
 public static object sendComment(string channelId, string content, string nonce, string parentMessageId)
 {
     return(new ThunkAction <AppState>((dispatcher, getState) => {
         return ArticleApi.SendComment(channelId, content, nonce, parentMessageId)
         .Then(message => {
             CustomDialogUtils.hiddenCustomDialog();
             CustomDialogUtils.showToast("发送成功", Icons.sentiment_satisfied);
             dispatcher.dispatch(new SendCommentSuccessAction {
                 message = message
             });
         })
         .Catch(error => {
             CustomDialogUtils.hiddenCustomDialog();
             CustomDialogUtils.showToast("发送失败", Icons.sentiment_dissatisfied);
         });
     }));
 }
Beispiel #19
0
        public static object removeLikeComment(Message message)
        {
            if (HttpManager.isNetWorkError())
            {
                CustomDialogUtils.showToast("请检查网络", iconData: Icons.sentiment_dissatisfied);
                return(null);
            }

            return(new ThunkAction <AppState>((dispatcher, getState) => {
                CustomDialogUtils.showToast("已取消点赞", iconData: Icons.sentiment_satisfied);
                dispatcher.dispatch(new RemoveLikeCommentSuccessAction {
                    message = message
                });
                return ArticleApi.RemoveLikeComment(commentId: message.id)
                .Then(mess => { })
                .Catch(error => { });
            }));
        }
Beispiel #20
0
        public static object likeArticle(string articleId)
        {
            if (HttpManager.isNetWorkError())
            {
                CustomDialogUtils.showToast("请检查网络", iconData: Icons.sentiment_dissatisfied);
                return(null);
            }

            return(new ThunkAction <AppState>((dispatcher, getState) => {
                CustomDialogUtils.showToast("点赞成功", iconData: Icons.sentiment_satisfied);
                dispatcher.dispatch(new LikeArticleSuccessAction {
                    articleId = articleId
                });
                return ArticleApi.LikeArticle(articleId: articleId)
                .Then(() => { })
                .Catch(_ => { });
            }));
        }
Beispiel #21
0
 public static object fetchFollowArticles(int pageNumber, string beforeTime, string afterTime, bool isFirst,
                                          bool isHot)
 {
     return(new ThunkAction <AppState>((dispatcher, getState) => {
         return ArticleApi.FetchFollowArticles(pageNumber: pageNumber, beforeTime: beforeTime,
                                               afterTime: afterTime, isFirst: isFirst, isHot: isHot)
         .Then(followArticlesResponse => {
             dispatcher.dispatch(new ArticleMapAction
             {
                 articleMap = followArticlesResponse.projectSimpleMap
             });
             dispatcher.dispatch(new UserMapAction {
                 userMap = followArticlesResponse.userMap
             });
             dispatcher.dispatch(new UserLicenseMapAction
             {
                 userLicenseMap = followArticlesResponse.userLicenseMap
             });
             dispatcher.dispatch(new TeamMapAction {
                 teamMap = followArticlesResponse.teamMap
             });
             dispatcher.dispatch(new FollowMapAction {
                 followMap = followArticlesResponse.followMap
             });
             dispatcher.dispatch(new LikeMapAction {
                 likeMap = followArticlesResponse.likeMap
             });
             dispatcher.dispatch(new FetchFollowArticleSuccessAction {
                 feeds = followArticlesResponse.feeds,
                 feedHasNew = followArticlesResponse.feedHasNew,
                 feedIsFirst = followArticlesResponse.feedIsFirst,
                 feedHasMore = followArticlesResponse.feedHasMore,
                 hotItems = followArticlesResponse.hotItems,
                 hotHasMore = followArticlesResponse.hotHasMore,
                 hotPage = followArticlesResponse.hotPage,
                 pageNumber = pageNumber
             });
         })
         .Catch(error => {
             dispatcher.dispatch(new FetchFollowArticleFailureAction());
             Debuger.LogError(message: error);
         });
     }));
 }
Beispiel #22
0
 public static object fetchArticles(string userId, int offset)
 {
     return(new ThunkAction <AppState>((dispatcher, getState) => {
         var articleOffset = getState().articleState.recommendArticleIds.Count;
         if (offset != 0 && offset != articleOffset)
         {
             offset = articleOffset;
         }
         return ArticleApi.FetchArticles(userId: userId, offset: offset)
         .Then(articlesResponse => {
             var articleList = new List <Article>();
             articlesResponse.hottests.ForEach(item => {
                 if (articlesResponse.projectMap.ContainsKey(key: item.itemId))
                 {
                     var article = articlesResponse.projectMap[key: item.itemId];
                     articleList.Add(item: article);
                 }
             });
             dispatcher.dispatch(new UserMapAction {
                 userMap = articlesResponse.userMap
             });
             dispatcher.dispatch(new TeamMapAction {
                 teamMap = articlesResponse.teamMap
             });
             dispatcher.dispatch(new FollowMapAction {
                 followMap = articlesResponse.followMap
             });
             dispatcher.dispatch(new LikeMapAction {
                 likeMap = articlesResponse.likeMap
             });
             dispatcher.dispatch(new FetchArticleSuccessAction {
                 offset = offset,
                 hottestHasMore = articlesResponse.hottestHasMore,
                 articleList = articleList,
                 feedHasNew = articlesResponse.feedHasNew
             });
         })
         .Catch(error => {
             dispatcher.dispatch(new FetchArticleFailureAction());
             Debuger.LogError(message: error);
         });
     }));
 }
        public static void RunExample(Configuration configuration)
        {
            try
            {
                ArticleApi articleApi = new ArticleApi(configuration);
                // create or replace
                Console.WriteLine("------------- Create or replace articles");
                List <Article> articlesList = new List <Article>();
                articlesList.Add(CreateArticle());
                articleApi.CreateOrReplaceArticles(articlesList);

                // get quantity
                Console.WriteLine("------------- Retrieving article quantity");
                long?quantity = articleApi.GetArticleQuantity().Quantity;
                Console.WriteLine("article quantity = " + quantity);
            }
            catch (ApiException e)
            {
                Console.WriteLine(e);
            }

            Console.ReadKey();
        }
Beispiel #24
0
 public static object fetchArticleComments(string channelId, string currOldestMessageId = "")
 {
     return(new ThunkAction <AppState>((dispatcher, getState) => {
         return ArticleApi.FetchArticleComments(channelId, currOldestMessageId)
         .Then(responseComments => {
             var itemIds = new List <string>();
             var messageItems = new Dictionary <string, Message>();
             var userMap = new Dictionary <string, User>();
             responseComments.items.ForEach(message => {
                 itemIds.Add(message.id);
                 messageItems[message.id] = message;
                 if (userMap.ContainsKey(message.author.id))
                 {
                     userMap[message.author.id] = message.author;
                 }
                 else
                 {
                     userMap.Add(message.author.id, message.author);
                 }
             });
             dispatcher.dispatch(new UserMapAction {
                 userMap = userMap
             });
             var hasMore = responseComments.hasMore;
             var lastCommentId = responseComments.currOldestMessageId;
             dispatcher.dispatch(new FetchArticleCommentsSuccessAction {
                 channelId = channelId,
                 itemIds = itemIds,
                 messageItems = messageItems,
                 isRefreshList = false,
                 hasMore = hasMore,
                 currOldestMessageId = lastCommentId
             });
         })
         .Catch(Debug.Log);
     }));
 }
        public static object fetchArticles(string userId, int offset)
        {
            return(new ThunkAction <AppState>((dispatcher, getState) => {
                var articleOffset = getState().articleState.recommendArticleIds.Count;
                if (offset != 0 && offset != articleOffset)
                {
                    offset = articleOffset;
                }

                return ArticleApi.FetchArticles(userId: userId, offset: offset)
                .Then(articlesResponse => {
                    var articleList = new List <Article>();
                    articlesResponse.hottests.ForEach(item => {
                        if (articlesResponse.projectMap.ContainsKey(key: item.itemId))
                        {
                            var article = articlesResponse.projectMap[key: item.itemId];
                            articleList.Add(item: article);
                        }
                    });
                    dispatcher.dispatch(new UserMapAction {
                        userMap = articlesResponse.userMap
                    });
                    dispatcher.dispatch(new TeamMapAction {
                        teamMap = articlesResponse.teamMap
                    });
                    dispatcher.dispatch(new FollowMapAction {
                        followMap = articlesResponse.followMap
                    });
                    dispatcher.dispatch(new LikeMapAction {
                        likeMap = articlesResponse.likeMap
                    });
                    var homeSliderIds = new List <string>();
                    var homeTopCollectionIds = new List <string>();
                    var homeCollectionIds = new List <string>();
                    var homeBloggerIds = new List <string>();
                    if (articlesResponse.rankData != null)
                    {
                        // 轮播图
                        var homeSlider = articlesResponse.rankData.homeSlider ?? new HomeSlider();
                        dispatcher.dispatch(new RankListAction {
                            rankList = homeSlider.rankList
                        });
                        (homeSlider.rankList ?? new List <RankData>()).ForEach(rankData => {
                            homeSliderIds.Add(item: rankData.id);
                        });

                        // 推荐榜单
                        var homeTopCollection = articlesResponse.rankData.homeTopCollection ?? new HomeCollection();
                        dispatcher.dispatch(new RankListAction {
                            rankList = homeTopCollection.rankList
                        });
                        dispatcher.dispatch(new FavoriteTagMapAction {
                            favoriteTagMap = homeTopCollection.favoriteTagMap
                        });
                        dispatcher.dispatch(new FavoriteTagArticleMapAction {
                            favoriteTagArticleMap = homeTopCollection.favoriteTagArticleMap
                        });
                        dispatcher.dispatch(new CollectedTagMapAction {
                            collectedTagMap = homeTopCollection.collectedTagMap
                        });
                        (homeTopCollection.rankList ?? new List <RankData>()).ForEach(rankData => {
                            homeTopCollectionIds.Add(item: rankData.id);
                        });

                        // 榜单
                        var homeCollection = articlesResponse.rankData.homeCollection ?? new HomeCollection();
                        dispatcher.dispatch(new RankListAction {
                            rankList = homeCollection.rankList
                        });
                        dispatcher.dispatch(new FavoriteTagMapAction {
                            favoriteTagMap = homeCollection.favoriteTagMap
                        });
                        dispatcher.dispatch(new FavoriteTagArticleMapAction {
                            favoriteTagArticleMap = homeCollection.favoriteTagArticleMap
                        });
                        dispatcher.dispatch(new CollectedTagMapAction {
                            collectedTagMap = homeCollection.collectedTagMap
                        });
                        (homeCollection.rankList ?? new List <RankData>()).ForEach(rankData => {
                            homeCollectionIds.Add(item: rankData.id);
                        });

                        // 推荐博主
                        var homeBlogger = articlesResponse.rankData.homeBlogger ?? new FetchBloggerResponse();
                        dispatcher.dispatch(new RankListAction {
                            rankList = homeBlogger.rankList
                        });
                        dispatcher.dispatch(new UserMapAction {
                            userMap = homeBlogger.userFullMap
                        });
                        dispatcher.dispatch(new FollowMapAction {
                            followMap = homeBlogger.followMap
                        });
                        dispatcher.dispatch(new UserLicenseMapAction {
                            userLicenseMap = homeBlogger.userLicenseMap
                        });
                        (homeBlogger.rankList ?? new List <RankData>()).ForEach(rankData => {
                            homeBloggerIds.Add(item: rankData.id);
                        });
                    }

                    dispatcher.dispatch(new FetchArticleSuccessAction {
                        offset = offset,
                        hottestHasMore = articlesResponse.hottestHasMore,
                        articleList = articleList,
                        feedHasNew = articlesResponse.feedHasNew,
                        homeSliderIds = homeSliderIds,
                        homeTopCollectionIds = homeTopCollectionIds,
                        homeCollectionIds = homeCollectionIds,
                        homeBloggerIds = homeBloggerIds,
                        searchSuggest = articlesResponse.rankData?.searchSuggest,
                        dailySelectionId = articlesResponse.rankData?.dailySelectionId,
                        leaderBoardUpdatedTime = articlesResponse.rankData.leaderboardUpdatedTime
                    });
                })
                .Catch(error => {
                    dispatcher.dispatch(new FetchArticleFailureAction());
                    Debuger.LogError(message: error);
                });
            }));
        }
Beispiel #26
0
 public EditForm()
 {
     InitializeComponent();
     _articleApi = ArticleApi.Instance;
 }
Beispiel #27
0
        public static object FetchArticleDetail(string articleId, bool isPush = false)
        {
            return(new ThunkAction <AppState>((dispatcher, getState) => {
                return ArticleApi.FetchArticleDetail(articleId: articleId, isPush: isPush)
                .Then(articleDetailResponse => {
                    var itemIds = new List <string>();
                    var messageItems = new Dictionary <string, Message>();
                    var userMap = new Dictionary <string, User>();
                    articleDetailResponse.project.comments.items.ForEach(message => {
                        itemIds.Add(item: message.id);
                        messageItems[key: message.id] = message;
                        if (userMap.ContainsKey(key: message.author.id))
                        {
                            userMap[key: message.author.id] = message.author;
                        }
                        else
                        {
                            userMap.Add(key: message.author.id, value: message.author);
                        }
                    });
                    articleDetailResponse.project.comments.parents.ForEach(message => {
                        if (messageItems.ContainsKey(key: message.id))
                        {
                            messageItems[key: message.id] = message;
                        }
                        else
                        {
                            messageItems.Add(key: message.id, value: message);
                        }

                        if (userMap.ContainsKey(key: message.author.id))
                        {
                            userMap[key: message.author.id] = message.author;
                        }
                        else
                        {
                            userMap.Add(key: message.author.id, value: message.author);
                        }
                    });
                    articleDetailResponse.project.comments.uppers.ForEach(message => {
                        if (messageItems.ContainsKey(key: message.id))
                        {
                            messageItems[key: message.id] = message;
                        }
                        else
                        {
                            messageItems.Add(key: message.id, value: message);
                        }

                        if (userMap.ContainsKey(key: message.author.id))
                        {
                            userMap[key: message.author.id] = message.author;
                        }
                        else
                        {
                            userMap.Add(key: message.author.id, value: message.author);
                        }
                    });
                    dispatcher.dispatch(new UserMapAction {
                        userMap = userMap
                    });
                    dispatcher.dispatch(new UserLicenseMapAction
                    {
                        userLicenseMap = articleDetailResponse.project.userLicenseMap
                    });
                    dispatcher.dispatch(new FetchArticleCommentsSuccessAction {
                        channelId = articleDetailResponse.project.channelId,
                        itemIds = itemIds,
                        messageItems = messageItems,
                        isRefreshList = true,
                        hasMore = articleDetailResponse.project.comments.hasMore,
                        currOldestMessageId = articleDetailResponse.project.comments.currOldestMessageId
                    });

                    dispatcher.dispatch(new UserMapAction {
                        userMap = articleDetailResponse.project.userMap
                    });
                    dispatcher.dispatch(new UserMapAction {
                        userMap = articleDetailResponse.project.mentionUsers
                    });
                    dispatcher.dispatch(new TeamMapAction {
                        teamMap = articleDetailResponse.project.teamMap
                    });
                    dispatcher.dispatch(new FollowMapAction {
                        followMap = articleDetailResponse.project.followMap
                    });
                    dispatcher.dispatch(new FetchArticleDetailSuccessAction {
                        articleDetail = articleDetailResponse.project,
                        articleId = articleId
                    });
                    dispatcher.dispatch(new SaveArticleHistoryAction {
                        article = articleDetailResponse.project.projectData
                    });
                })
                .Catch(error => {
                    dispatcher.dispatch(new FetchArticleDetailFailureAction());
                    Debuger.LogError(message: error);
                });
            }));
        }