Exemple #1
0
		public async Task<bool> Rename(string newLabel)
		{
			if (await FeedManager.RenameFeedGroup(this, newLabel))
			{
				this.Label = newLabel;

				await FeedManager.SaveOne(this);

				return true;
			}
			else
			{
				return false;
			}
		}
Exemple #2
0
        private HohoemaApp(IEventAggregator ea)
        {
            EventAggregator           = ea;
            NiconicoContext           = new NiconicoContext();
            LoginUserId               = uint.MaxValue;
            LoggingChannel            = new LoggingChannel("HohoemaLog", new LoggingChannelOptions(HohoemaLoggerGroupGuid));
            UserSettings              = new HohoemaUserSettings();
            ContentFinder             = new NiconicoContentFinder(this);
            UserMylistManager         = new UserMylistManager(this);
            OtherOwneredMylistManager = new OtherOwneredMylistManager(ContentFinder);
            FeedManager               = new FeedManager(this);

            FollowManager = null;

            _SigninLock = new SemaphoreSlim(1, 1);

            BackgroundUpdater = new BackgroundUpdater("HohoemaBG", UIDispatcher);

            ApplicationData.Current.DataChanged += Current_DataChanged;


            UpdateServiceStatus();
            NetworkInformation.NetworkStatusChanged += NetworkInformation_NetworkStatusChanged;
        }
Exemple #3
0
		private async Task _Refresh()
		{
			if (!IsNeedRefresh) { return; }

			Debug.WriteLine($"{Label} starting update feed.");

			var updateTime = DateTime.Now;
			var latestItems = new List<FeedItem>();
			foreach (var feedSource in _FeedSourceList)
			{
				var items = await feedSource.GetLatestItems(HohoemaApp);
				foreach (var item in items)
				{
					latestItems.Add(item);
				}
			}


			var latestOrderedItems = latestItems
				.OrderByDescending(x => x.SubmitDate)
				.Take(MaxFeedItemsCount)
				.ToList();

			foreach (var item in latestOrderedItems)
			{
				item.CheckedTime = updateTime;
			}

			var exceptItems = latestOrderedItems.Except(FeedItems, FeedItemComparer.Default).ToList();

			var addedItems = exceptItems.Where(x => x.CheckedTime == updateTime);

			var removedItems = FeedItems
				.Except(latestOrderedItems, FeedItemComparer.Default)
				.Where(x => x.CheckedTime != updateTime)
				.ToList();


			foreach (var addItem in addedItems)
			{
				addItem.IsUnread = true;

				// 投稿日時が初期化されていない場合はThumbnailInfoから拾ってくる

				// ユーザー動画取得の場合に投稿時刻が取れないことが原因
				// 追加されたアイテムだけのThumbnailを取得することで無駄な処理を減らす
				if (addItem.SubmitDate == default(DateTime))
				{
					try
					{
						var nicoVideo = await HohoemaApp.MediaManager.GetNicoVideoAsync(addItem.VideoId);
						
						addItem.SubmitDate = nicoVideo.PostedAt;
					}
					catch (Exception ex)
					{
						Debug.Fail("UserFeedItem 更新中、NicoVideoオブジェクトの取得に失敗しました。", ex.Message);
					}
				}
				

				FeedItems.Add(addItem);
			}

			foreach (var removedItem in removedItems)
			{
				var item = FeedItems.SingleOrDefault(x => x.VideoId == removedItem.VideoId);
				if (item != null)
				{
					item.IsDeleted = true;
					FeedItems.Remove(item);
				}

			}

			FeedItems.Sort(FeedItemComparer.Default);

			UpdateTime = updateTime;

			await FeedManager.SaveOne(this);

            Completed?.Invoke(this);

            IsNeedRefresh = false;

			Debug.WriteLine($"{Label} update feed done.");
		}
Exemple #4
0
		public async Task Refresh()
		{
			IsNeedRefresh = true;
			await FeedManager.RefreshOneAsync(this);
		}