Ejemplo n.º 1
0
        protected override async Task <int> ResetSourceImpl()
        {
            try
            {
                _userMylists = await _mylistRepository.GetUserMylistsAsync(UserId);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }

            return(_userMylists?.Count ?? 0);
        }
Ejemplo n.º 2
0
        public async Task OnNavigatedToAsync(INavigationParameters parameters)
        {
            string userId = null;

            if (parameters.TryGetValue <string>("id", out var id))
            {
                userId = id;
            }

            if (userId == UserId)
            {
                return;
            }

            UserId = userId;


            // ログインユーザーと同じ場合、お気に入り表示をOFFに
            IsLoginUser = NiconicoSession.UserId.ToString() == userId;

            IsLoadFailed = false;

            VideoInfoItems.Clear();

            try
            {
                var userInfo = await UserProvider.GetUserDetail(UserId);

                var user = userInfo;
                UserName    = user.Nickname;
                UserIconUri = user.ThumbnailUri;

                FollowerCount  = user.FollowerCount;
                StampCount     = user.StampCount;
                VideoCount     = user.TotalVideoCount;
                IsVideoPrivate = user.IsOwnerVideoPrivate;
            }
            catch
            {
                IsLoadFailed = true;
            }


            if (UserId == null)
            {
                return;
            }


            // NGユーザーの設定

            if (!IsLoginUser)
            {
                var ngResult = NgSettings.IsNgVideoOwnerId(UserId);
                IsNGVideoOwner.Value = ngResult != null;
            }
            else
            {
                IsNGVideoOwner.Value = false;
            }

            try
            {
                await Task.Delay(500);

                var userVideos = await UserProvider.GetUserVideos(uint.Parse(UserId), 1);

                foreach (var item in userVideos.Items.Take(5))
                {
                    var vm = new VideoInfoControlViewModel(item.VideoId);
                    vm.SetTitle(item.Title);
                    vm.SetThumbnailImage(item.ThumbnailUrl.OriginalString);
                    VideoInfoItems.Add(vm);
                }
                RaisePropertyChanged(nameof(VideoInfoItems));
            }
            catch (Exception ex)
            {
                IsLoadFailed = true;
                Debug.WriteLine(ex.Message);
            }

            HasOwnerVideo = VideoInfoItems.Count != 0;


            if (NiconicoSession.IsLoginUserId(UserId))
            {
                MylistGroups = UserMylistManager.Mylists;
            }
            else
            {
                try
                {
                    //					await Task.Delay(500);
                    MylistGroups = await _mylistRepository.GetUserMylistsAsync(UserId);
                }
                catch (Exception ex)
                {
                    IsLoadFailed = true;
                    Debug.WriteLine(ex.Message);
                }
            }
            RaisePropertyChanged(nameof(MylistGroups));


            UserBookmark = Database.BookmarkDb.Get(Database.BookmarkType.User, UserId)
                           ?? new Database.Bookmark()
            {
                Content      = UserId,
                Label        = UserName,
                BookmarkType = Database.BookmarkType.User
            };

            RaisePropertyChanged(nameof(UserBookmark));


            FollowToggleButtonService.SetFollowTarget(this);
        }