protected override async Task <IAsyncEnumerable <HohoemaListingPageItemBase> > GetPagedItemsImpl(int head, int count) { var tail = head + count; var prevCount = TimelineItems.Count; if (TimelineItems.Count < tail) { while (prevCount == TimelineItems.Count) { var nicoRepoResponse = await LoginUserNicoRepoProvider.GetLoginUserNicoRepo(NicoRepoTimelineType.all, _LastItem?.Id); if (nicoRepoResponse.IsStatusOK) { foreach (var item in nicoRepoResponse.TimelineItems) { if (CheckCanDisplayTimelineItem(item)) { TimelineItems.Add(item); } } _LastItem = nicoRepoResponse.LastTimelineItem; if (nicoRepoResponse.TimelineItems.Count == 0) { break; } } else { break; } } } var list = new List <HohoemaListingPageItemBase>(); return(TimelineItems.Skip(head).Take(count).ToArray() .Select <NicoRepoTimelineItem, HohoemaListingPageItemBase>(item => { var topicType = NicoRepoItemTopicExtension.ToNicoRepoTopicType(item.Topic); if (topicType == NicoRepoItemTopic.Live_User_Program_OnAirs || topicType == NicoRepoItemTopic.Live_User_Program_Reserve || topicType == NicoRepoItemTopic.Live_Channel_Program_Onairs || topicType == NicoRepoItemTopic.Live_Channel_Program_Reserve) { return new NicoRepoLiveTimeline(item, topicType); } else if (topicType == NicoRepoItemTopic.NicoVideo_User_Video_Upload || topicType == NicoRepoItemTopic.NicoVideo_User_Mylist_Add_Video || topicType == NicoRepoItemTopic.NicoVideo_Channel_Video_Upload) { return new NicoRepoVideoTimeline(item, topicType); } else { throw new NotSupportedException(topicType.ToString()); } }) .ToAsyncEnumerable()); }
private bool CheckCanDisplayTimelineItem(NicoRepoTimelineItem item) { var topicType = NicoRepoItemTopicExtension.ToNicoRepoTopicType(item.Topic); if (!AllowedNicoRepoItemType.Any(x => x == topicType)) { return(false); } if (topicType == NicoRepoItemTopic.Live_User_Program_OnAirs || topicType == NicoRepoItemTopic.Live_User_Program_Reserve || topicType == NicoRepoItemTopic.Live_Channel_Program_Onairs || topicType == NicoRepoItemTopic.Live_Channel_Program_Reserve) { if (item.Program != null) { // 放送開始が現時点より6時間以上前の場合には既に終了済みとして表示しない if (item.Program.BeginAt < NiconamaDisplayTime) { return(false); } } return(true); } else { return(true); } }