Ejemplo n.º 1
0
        public async Task Load(ListWindowPageType pageType)
        {
            PageType = pageType;
            OfUser   = await _livemeApiProvider
                       .GetUserInfo(UserId, CancellationToken.None)
                       .ConfigureAwait(true);

            NofifyChanged();

            await LoadMore().ConfigureAwait(true);
        }
        public async Task LoadUser(string uid, CancellationToken token)
        {
            try
            {
                Replays.Clear();

                ViewStatus = MainViewStatus.LoadingProfile;

                try
                {
                    Loading = uid;
                    User    = await _liveMeApi.GetUserInfo(uid, token).ConfigureAwait(true);

                    IsBookmarked = _dataAccess.IsBookmarked(uid);
                }
                catch (Exception)
                {
                    ViewStatus = MainViewStatus.ProfileNotFound;
                    return;
                }

                _dataAccess.SetProfileToSeen(uid);


                await LoadReplays(uid, token);
            }

            catch (Exception e)
            {
                _logger.LogError(e.ToString());
            }

            NofifyChanged();
        }
        private async Task ScanBookmark(Bookmark bookmark, Action <ScanResult> onScanFound, Action <double> progress)
        {
            var liveMeUser = await _liveMeApi.GetUserInfo(bookmark.Uid, CancellationToken.None);

//            lock (_footerViewModel)
//            {
//                Count++;
//                progress(Count / TotalCount);
//                _footerViewModel.FooterInfo = $"Scanning {Count} / {TotalCount} bookmarks";
//            }

            //await JsInteropHelper.CallAndGet<object>("scanFooterInfo", current, totalLength);

            var newReplays    = bookmark.ReplayCount < liveMeUser.CountInfo.VideoCount;
            var newFans       = bookmark.FollowerCount < liveMeUser.CountInfo.FollowerCount;
            var newFollowings = bookmark.FollowingCount < liveMeUser.CountInfo.FollowingCount;
            var showReplays   = bookmark.BookmarkType == BookmarkType.Default ||
                                bookmark.BookmarkType == BookmarkType.Streamer;
            var showFans = bookmark.BookmarkType == BookmarkType.Default ||
                           bookmark.BookmarkType == BookmarkType.Streamer;
            var showFollowings = bookmark.BookmarkType == BookmarkType.Default ||
                                 bookmark.BookmarkType == BookmarkType.Follower;

            if (newReplays && showReplays)

            {
                var delta = (int)(liveMeUser.CountInfo.VideoCount - bookmark.ReplayCount);
                onScanFound(new ScanResult
                {
                    Delta    = delta,
                    ScanType = ScanType.NewReplays,
                    Bookmark = bookmark
                });
            }

            if (newFollowings && showFollowings)
            {
                var delta = (int)(liveMeUser.CountInfo.FollowingCount - bookmark.FollowingCount);
                onScanFound(new ScanResult
                {
                    Delta    = delta,
                    ScanType = ScanType.NewFollowings,
                    Bookmark = bookmark
                });
            }

            if (newFans && showFans)
            {
                var delta = (int)(liveMeUser.CountInfo.FollowerCount - bookmark.FollowerCount);
                onScanFound(new ScanResult
                {
                    Delta    = delta,
                    ScanType = ScanType.NewFans,
                    Bookmark = bookmark
                });
            }

            if (newFans || newFollowings || newReplays)
            {
                _db.UpdateBookmark(bookmark.Uid, liveMeUser);
            }
        }