示例#1
0
        internal void AddOrUpdateFeedResultSet(Models.Subscription.SubscriptionSource source, IEnumerable <string> items)
        {
            FeedResultItems = FeedResultItems ?? new List <FeedResultSet>();
            var item = FeedResultItems.FirstOrDefault(x => x.SourceType == source.SourceType && x.Parameter == source.Parameter)
            ;

            if (item != null)
            {
                FeedResultItems.Remove(item);
            }
            else
            {
                item = new FeedResultSet()
                {
                    SourceType = source.SourceType, Parameter = source.Parameter
                };
            }

            item.NewItems    = items?.ToList() ?? new List <string>();
            item.Items       = (item.Items ?? new List <string>()).Concat(item.NewItems).Where(x => x != null).Distinct().ToList();
            item.LastUpdated = DateTime.Now;

            FeedResultItems.Add(item);
        }
示例#2
0
        protected override async void Execute(object parameter)
        {
            if (parameter is Models.Subscription.Subscription subscription)
            {
                // フォローしているアイテムから選択できるように
                // (コミュニティを除く)
                var selectableContents = FollowManager.GetAllFollowInfoGroups()
                                         .Select(x => new ChoiceFromListSelectableContainer(x.FollowItemType.Translate(),
                                                                                            x.FollowInfoItems.Where(y => y.FollowItemType != Models.FollowItemType.Community).Select(y => new SelectDialogPayload()
                {
                    Label   = y.Name,
                    Id      = y.Id,
                    Context = y
                })));

                var keywordInput = new TextInputSelectableContainer("キーワード検索", null);

                var result = await DialogService.ShowContentSelectDialogAsync(
                    $"『{subscription.Label}』へ購読を追加",
                    Enumerable.Concat <ISelectableContainer>(new[] { keywordInput }, selectableContents)
                    );

                if (result != null)
                {
                    Models.Subscription.SubscriptionSource?source = null;
                    if (result.Context is Models.FollowItemInfo followInfo)
                    {
                        Models.Subscription.SubscriptionSourceType?sourceType = null;
                        switch (followInfo.FollowItemType)
                        {
                        case Models.FollowItemType.Tag:
                            sourceType = Models.Subscription.SubscriptionSourceType.TagSearch;
                            break;

                        case Models.FollowItemType.Mylist:
                            sourceType = Models.Subscription.SubscriptionSourceType.Mylist;
                            break;

                        case Models.FollowItemType.User:
                            sourceType = Models.Subscription.SubscriptionSourceType.User;
                            break;

                        case Models.FollowItemType.Community:
                            break;

                        case Models.FollowItemType.Channel:
                            sourceType = Models.Subscription.SubscriptionSourceType.Channel;
                            break;

                        default:
                            break;
                        }

                        if (sourceType != null)
                        {
                            source = new Models.Subscription.SubscriptionSource(result.Label, sourceType.Value, result.Id);
                        }
                    }
                    else
                    {
                        source = new Models.Subscription.SubscriptionSource(result.Label, Models.Subscription.SubscriptionSourceType.KeywordSearch, result.Id);
                    }

                    if (subscription.AddSource.CanExecute(source))
                    {
                        subscription.AddSource.Execute(source);
                    }
                }
            }
        }
示例#3
0
        public static void AddOrUpdateFeedResult(Models.Subscription.Subscription subscription, Models.Subscription.SubscriptionSource source, IEnumerable <string> items)
        {
            var db = HohoemaLiteDb.GetTempLiteRepository();

            var feedResult = db.SingleOrDefault <SubscriptionFeedResult>(x => x.SubscriptionId == subscription.Id)
                             ?? new SubscriptionFeedResult()
            {
                SubscriptionId = subscription.Id
            }
            ;

            feedResult.AddOrUpdateFeedResultSet(source, items);

            db.Upsert(feedResult);
        }
示例#4
0
 public FeedResultSet GetFeedResultSet(Models.Subscription.SubscriptionSource source)
 {
     return(FeedResultItems?.FirstOrDefault(x => x.SourceType == source.SourceType && x.Parameter == source.Parameter)
            );
 }