protected override async Task ListPageNavigatedToAsync(CancellationToken cancelToken, NavigatedToEventArgs e, Dictionary <string, object> viewModelState) { if (IsValidCommunity) { try { var res = await CommunityProvider.GetCommunityDetail(CommunityId); CommunityDetail = res.CommunitySammary.CommunityDetail; CommunityName = CommunityDetail.Name; } catch { Debug.WriteLine("コミュ情報取得に失敗"); IsValidCommunity = false; } } else { Debug.WriteLine("CommunityID は無効: " + CommunityId); } await base.ListPageNavigatedToAsync(cancelToken, e, viewModelState); }
public override async Task OnNavigatedToAsync(INavigationParameters parameters) { if (parameters.TryGetValue("id", out string id)) { CommunityId = id; try { var res = await CommunityProvider.GetCommunityDetail(CommunityId); CommunityDetail = res.CommunitySammary.CommunityDetail; CommunityName = CommunityDetail.Name; } catch { Debug.WriteLine("コミュ情報取得に失敗"); } } await base.OnNavigatedToAsync(parameters); }
private async Task <InAppNotificationPayload> SubmitCommunityContentSuggestion(string communityId) { Mntone.Nico2.Communities.Detail.CommunityDetailResponse communityDetail = null; try { communityDetail = await CommunityProvider.GetCommunityDetail(communityId); } catch { } if (communityDetail == null || !communityDetail.IsStatusOK) { return(null); } var communityInfo = communityDetail.CommunitySammary.CommunityDetail; return(new InAppNotificationPayload() { Content = $"{communityInfo.Name} をお探しですか?", ShowDuration = DefaultNotificationShowDuration, SymbolIcon = Symbol.Video, IsShowDismissButton = true, Commands = { new InAppNotificationCommand() { Label = "コミュニティを開く", Command = new DelegateCommand(() => { PageManager.OpenPageWithId(HohoemaPageType.Community, communityId); NotificationService.DismissInAppNotification(); }) }, } }); }
public async Task OnNavigatedToAsync(INavigationParameters parameters) { // ナビゲーションパラメータからコミュニティIDを取得 IsFailed = false; try { NowLoading = true; if (parameters.TryGetValue("id", out string id)) { CommunityId = id; var res = await CommunityProvider.GetCommunityInfo(CommunityId); if (res == null || !res.IsStatusOK) { return; } CommunityInfo = res.Community; RaisePropertyChanged(nameof(CommunityName)); RaisePropertyChanged(nameof(IsPublic)); RaisePropertyChanged(nameof(CommunityDescription)); RaisePropertyChanged(nameof(IsOfficial)); RaisePropertyChanged(nameof(MaxUserCount)); RaisePropertyChanged(nameof(UserCount)); RaisePropertyChanged(nameof(CommunityLevel)); RaisePropertyChanged(nameof(CreatedAt)); RaisePropertyChanged(nameof(ThumbnailUrl)); RaisePropertyChanged(nameof(TopUrl)); var detail = await CommunityProvider.GetCommunityDetail(CommunityId); if (detail == null && !detail.IsStatusOK) { return; } CommunityDetail = detail.CommunitySammary.CommunityDetail; ApplicationTheme appTheme; if (_appearanceSettings.Theme == ElementTheme.Dark) { appTheme = ApplicationTheme.Dark; } else if (_appearanceSettings.Theme == ElementTheme.Light) { appTheme = ApplicationTheme.Light; } else { appTheme = Views.Helpers.SystemThemeHelper.GetSystemTheme(); } var profileHtmlId = $"{CommunityId}_profile"; ProfileHtmlFileUri = await Models.Helpers.HtmlFileHelper.PartHtmlOutputToCompletlyHtml(profileHtmlId, CommunityDetail.ProfielHtml, appTheme); OwnerUserInfo = new UserInfoViewModel( CommunityDetail.OwnerUserName, CommunityDetail.OwnerUserId ); IsOwnedCommunity = NiconicoSession.UserId.ToString() == OwnerUserInfo.Id; Tags = CommunityDetail.Tags.Select(x => new NicoVideoTag(x)) .ToList(); FutureLiveList = CommunityDetail.FutureLiveList.Select(x => new CommunityLiveInfoViewModel(x)) .ToList(); RecentLiveList = CommunityDetail.RecentLiveList.Select(x => new CommunityLiveInfoViewModel(x)) .ToList(); NewsList = new List <CommunityNewsViewModel>(); foreach (var news in CommunityDetail.NewsList) { var newsVM = await CommunityNewsViewModel.Create(CommunityId, news.Title, news.PostAuthor, news.PostDate, news.ContentHtml, PageManager, _appearanceSettings); NewsList.Add(newsVM); } HasNews = NewsList.Count > 0; CurrentLiveInfoList = CommunityDetail.CurrentLiveList.Select(x => new CurrentLiveInfoViewModel(x, CommunityDetail)) .ToList(); HasCurrentLiveInfo = CurrentLiveInfoList.Count > 0; CommunityVideoSamples = new List <CommunityVideoInfoViewModel>(); foreach (var sampleVideo in CommunityDetail.VideoList) { var videoInfoVM = new CommunityVideoInfoViewModel(sampleVideo); CommunityVideoSamples.Add(videoInfoVM); } RaisePropertyChanged(nameof(CommunityOwnerName)); RaisePropertyChanged(nameof(VideoCount)); RaisePropertyChanged(nameof(PrivilegeDescription)); // RaisePropertyChanged(nameof(IsJoinAutoAccept)); // RaisePropertyChanged(nameof(IsJoinWithoutPrivacyInfo)); // RaisePropertyChanged(nameof(IsCanLiveOnlyPrivilege)); // RaisePropertyChanged(nameof(IsCanAcceptJoinOnlyPrivilege)); // RaisePropertyChanged(nameof(IsCanSubmitVideoOnlyPrivilege)); RaisePropertyChanged(nameof(ProfileHtmlFileUri)); RaisePropertyChanged(nameof(OwnerUserInfo)); RaisePropertyChanged(nameof(Tags)); RaisePropertyChanged(nameof(FutureLiveList)); RaisePropertyChanged(nameof(NewsList)); RaisePropertyChanged(nameof(HasNews)); RaisePropertyChanged(nameof(CurrentLiveInfoList)); RaisePropertyChanged(nameof(HasCurrentLiveInfo)); RaisePropertyChanged(nameof(CommunityVideoSamples)); // フォロー表示・操作の準備 // Note: オーナーコミュニティのフォローを解除=コミュニティの解散操作となるため注意が必要 // 安全管理上、アプリ上でコミュニティの解散は不可の方向に倒して対応したい if (!IsOwnedCommunity) { FollowToggleButtonService.SetFollowTarget(this); } else { FollowToggleButtonService.SetFollowTarget(null); } UpdateCanNotFollowReason(); } } catch (Exception ex) { Debug.WriteLine(ex.ToString()); IsFailed = true; } finally { NowLoading = false; } }
protected override async Task NavigatedToAsync(CancellationToken cancelToken, NavigatedToEventArgs e, Dictionary <string, object> viewModelState) { // ナビゲーションパラメータからコミュニティIDを取得 IsFailed = false; try { NowLoading = true; CommunityId = null; if (e.Parameter is string) { CommunityId = e.Parameter as string; } // コミュニティ情報の取得 if (!string.IsNullOrEmpty(CommunityId)) { var res = await CommunityProvider.GetCommunityInfo(CommunityId); if (res == null || !res.IsStatusOK) { return; } CommunityInfo = res.Community; RaisePropertyChanged(nameof(CommunityName)); RaisePropertyChanged(nameof(IsPublic)); RaisePropertyChanged(nameof(CommunityDescription)); RaisePropertyChanged(nameof(IsOfficial)); RaisePropertyChanged(nameof(MaxUserCount)); RaisePropertyChanged(nameof(UserCount)); RaisePropertyChanged(nameof(CommunityLevel)); RaisePropertyChanged(nameof(CreatedAt)); RaisePropertyChanged(nameof(ThumbnailUrl)); RaisePropertyChanged(nameof(TopUrl)); var detail = await CommunityProvider.GetCommunityDetail(CommunityId); if (detail == null && !detail.IsStatusOK) { return; } CommunityDetail = detail.CommunitySammary.CommunityDetail; var profileHtmlId = $"{CommunityId}_profile"; ProfileHtmlFileUri = await Models.Helpers.HtmlFileHelper.PartHtmlOutputToCompletlyHtml(profileHtmlId, CommunityDetail.ProfielHtml); OwnerUserInfo = new UserInfoViewModel( CommunityDetail.OwnerUserName, CommunityDetail.OwnerUserId ); IsOwnedCommunity = NiconicoSession.UserId.ToString() == OwnerUserInfo.Id; Tags = CommunityDetail.Tags.Select(x => new TagViewModel(x)) .ToList(); FutureLiveList = CommunityDetail.FutureLiveList.Select(x => new CommunityLiveInfoViewModel(x)) .ToList(); RecentLiveList = CommunityDetail.RecentLiveList.Select(x => new CommunityLiveInfoViewModel(x)) .ToList(); NewsList = new List <CommunityNewsViewModel>(); foreach (var news in CommunityDetail.NewsList) { var newsVM = await CommunityNewsViewModel.Create(CommunityId, news.Title, news.PostAuthor, news.PostDate, news.ContentHtml, PageManager); NewsList.Add(newsVM); } HasNews = NewsList.Count > 0; CurrentLiveInfoList = CommunityDetail.CurrentLiveList.Select(x => new CurrentLiveInfoViewModel(x, CommunityDetail)) .ToList(); HasCurrentLiveInfo = CurrentLiveInfoList.Count > 0; CommunityVideoSamples = new List <CommunityVideoInfoViewModel>(); foreach (var sampleVideo in CommunityDetail.VideoList) { var videoInfoVM = new CommunityVideoInfoViewModel(sampleVideo); CommunityVideoSamples.Add(videoInfoVM); } RaisePropertyChanged(nameof(CommunityOwnerName)); RaisePropertyChanged(nameof(VideoCount)); RaisePropertyChanged(nameof(PrivilegeDescription)); // RaisePropertyChanged(nameof(IsJoinAutoAccept)); // RaisePropertyChanged(nameof(IsJoinWithoutPrivacyInfo)); // RaisePropertyChanged(nameof(IsCanLiveOnlyPrivilege)); // RaisePropertyChanged(nameof(IsCanAcceptJoinOnlyPrivilege)); // RaisePropertyChanged(nameof(IsCanSubmitVideoOnlyPrivilege)); RaisePropertyChanged(nameof(ProfileHtmlFileUri)); RaisePropertyChanged(nameof(OwnerUserInfo)); RaisePropertyChanged(nameof(Tags)); RaisePropertyChanged(nameof(FutureLiveList)); RaisePropertyChanged(nameof(NewsList)); RaisePropertyChanged(nameof(HasNews)); RaisePropertyChanged(nameof(CurrentLiveInfoList)); RaisePropertyChanged(nameof(HasCurrentLiveInfo)); RaisePropertyChanged(nameof(CommunityVideoSamples)); // フォロー表示・操作の準備 // Note: オーナーコミュニティのフォローを解除=コミュニティの解散操作となるため注意が必要 // 安全管理上、アプリ上でコミュニティの解散は不可の方向に倒して対応したい if (!IsOwnedCommunity) { FollowToggleButtonService.SetFollowTarget(this); } else { FollowToggleButtonService.SetFollowTarget(null); } UpdateCanNotFollowReason(); } } catch (Exception ex) { Debug.WriteLine(ex.ToString()); IsFailed = true; } finally { NowLoading = false; } }