Пример #1
0
        public static object cancelCollectFavoriteTag(string tagId, string itemId)
        {
            if (HttpManager.isNetWorkError())
            {
                CustomDialogUtils.showToast("请检查网络", iconData: Icons.sentiment_dissatisfied);
                return(null);
            }

            return(new ThunkAction <AppState>((dispatcher, getState) => {
                dispatcher.dispatch(new ChangeFavoriteTagStateAction {
                    isLoading = true
                });
                return FavoriteApi.DeleteFavoriteTag(tagId: tagId, itemId.isNotEmpty() ? "" : tagId)
                .Then(deleteFavoriteTagResponse => {
                    dispatcher.dispatch(new DeleteFavoriteTagSuccessAction {
                        favoriteTag = deleteFavoriteTagResponse
                    });
                    dispatcher.dispatch(new CancelCollectFavoriteTagSuccessAction
                    {
                        itemId = itemId.isEmpty() ? tagId : itemId
                    });
                    AnalyticsManager.AnalyticsHandleFavoriteTag(type: FavoriteTagType.cancelCollect);
                })
                .Catch(error => {
                    dispatcher.dispatch(new ChangeFavoriteTagStateAction());
                    Debuger.LogError(message: error);
                });
            }));
        }
Пример #2
0
        public static object deleteFavoriteTag(string tagId)
        {
            if (HttpManager.isNetWorkError())
            {
                CustomDialogUtils.showToast("请检查网络", iconData: Icons.sentiment_dissatisfied);
                return(null);
            }

            CustomDialogUtils.showCustomDialog(
                child: new CustomLoadingDialog(
                    message: "删除收藏夹中"
                    )
                );
            return(new ThunkAction <AppState>((dispatcher, getState) => {
                return FavoriteApi.DeleteFavoriteTag(tagId: tagId)
                .Then(deleteFavoriteTagResponse => {
                    CustomDialogUtils.hiddenCustomDialog();
                    dispatcher.dispatch(new DeleteFavoriteTagSuccessAction {
                        favoriteTag = deleteFavoriteTagResponse
                    });
                    AnalyticsManager.AnalyticsHandleFavoriteTag(type: FavoriteTagType.delete);
                })
                .Catch(error => {
                    CustomDialogUtils.hiddenCustomDialog();
                    Debuger.LogError(message: error);
                });
            }));
        }
Пример #3
0
        public static object collectFavoriteTag(string itemId, string rankDataId = "", string tagId = "")
        {
            if (HttpManager.isNetWorkError())
            {
                CustomDialogUtils.showToast("请检查网络", iconData: Icons.sentiment_dissatisfied);
                return(null);
            }

            return(new ThunkAction <AppState>((dispatcher, getState) => {
                dispatcher.dispatch(new ChangeFavoriteTagStateAction {
                    isLoading = true
                });
                return FavoriteApi.CollectFavoriteTag(tagId: itemId)
                .Then(collectFavoriteTagResponse => {
                    dispatcher.dispatch(new CreateFavoriteTagSuccessAction {
                        favoriteTag = collectFavoriteTagResponse.favoriteTag,
                        isCollection = true
                    });
                    dispatcher.dispatch(new CollectFavoriteTagSuccessAction {
                        myFavoriteTagId = collectFavoriteTagResponse.favoriteTag.id,
                        rankDataId = rankDataId,
                        itemId = itemId,
                        tagId = tagId
                    });


                    AnalyticsManager.AnalyticsHandleFavoriteTag(type: FavoriteTagType.collect);
                })
                .Catch(error => {
                    dispatcher.dispatch(new ChangeFavoriteTagStateAction());
                    Debuger.LogError(message: error);
                });
            }));
        }
Пример #4
0
        public static object editFavoriteTag(IconStyle iconStyle, string tagId, string name, string description = "")
        {
            if (HttpManager.isNetWorkError())
            {
                CustomDialogUtils.showToast("请检查网络", iconData: Icons.sentiment_dissatisfied);
                return(null);
            }

            CustomDialogUtils.showCustomDialog(
                child: new CustomLoadingDialog(
                    message: "编辑收藏夹中"
                    )
                );
            return(new ThunkAction <AppState>((dispatcher, getState) => {
                return FavoriteApi
                .EditFavoriteTag(tagId: tagId, iconStyle: iconStyle, name: name, description: description)
                .Then(editFavoriteTagResponse => {
                    CustomDialogUtils.hiddenCustomDialog();
                    dispatcher.dispatch(new EditFavoriteTagSuccessAction {
                        favoriteTag = editFavoriteTagResponse
                    });
                    dispatcher.dispatch(new MainNavigatorPopAction());
                    AnalyticsManager.AnalyticsHandleFavoriteTag(type: FavoriteTagType.edit);
                })
                .Catch(error => {
                    CustomDialogUtils.hiddenCustomDialog();
                    Debuger.LogError(message: error);
                });
            }));
        }