//コメント投下 public async void Post() { //連打して2回ポストされないように //割りと重要かなって if (PostPending || Text.TrimEnd().Length == 0) { return; } PostPending = true; var vpos = CurrentVpos; VideoCommentListViewModel target = null; if (Owner.Owner.ApiData.IsChannelVideo) { target = Owner.CommentListList.Where(e => e.CommentListInstance.ListName == "チャンネルコメント").First(); } else { target = Owner.CommentListList.Where(e => e.CommentListInstance.ListName == "通常コメント").First(); } //コメントを投稿してコメントナンバーを取得する var number = await Owner.CommentInstance.PostAsync(target.CommentListInstance, vpos, Mail, Text); //APIを叩いて返ってきたコメント番号をもとにhtml5で描画してみる //APIの応答が遅いと表示される前に描画タイミングが過ぎてしまうかもね if (number != -1) { var entry = new NicoNicoCommentEntry() { Number = number, Vpos = vpos, PostedAt = UnixTime.ToUnixTime(DateTime.Now), Anonymity = Settings.Instance.Use184, UserId = App.ViewModelRoot.CurrentUser.UserId, Mail = Mail, Content = Text, JustPosted = true }; entry.DisassembleMail(); target.CommentList.Add(new VideoCommentEntryViewModel(Owner, entry)); //TextBoxを空にする Text = ""; } //処理終わり PostPending = false; }
public async void Refresh() { IsActive = true; var targetList = CommentListList.Select(e => e.CommentListInstance).ToList(); CommentListList.Clear(); //コメントを取得できるやつは取得する foreach (var list in await CommentInstance.RefreshCommentAsync(targetList)) { var listlist = new VideoCommentListViewModel(list); foreach (var entry in list.CommentList) { listlist.CommentList.Add(new VideoCommentEntryViewModel(this, entry)); } CommentListList.Add(listlist); } if (CommentListList.Count > 0) { SelectedList = CommentListList.First(); } IsActive = false; CanComment = true; Owner?.Handler?.InvokeScript("CommentViewModel$initialize"); if (CommentVisibility) { Owner?.Handler?.InvokeScript("CommentViewModel$show_comment"); } else { Owner?.Handler?.InvokeScript("CommentViewModel$hide_comment"); } }
public async Task Initialize() { IsActive = true; CommentListList.Clear(); var lists = await CommentInstance.GetAllCommentAsync(); if (lists == null) { return; } //コメントを取得できるやつは取得する foreach (var list in lists) { var listlist = new VideoCommentListViewModel(list); foreach (var entry in list.CommentList) { //コメントをふるいにかける App.ViewModelRoot.Setting.NGFilter.Filter(entry); if (entry.Rejected) { continue; } //投稿者コメントでかつ@で始まるニコスクリプトだったら if (entry.IsUploader && entry.Content.StartsWith("@")) { var match = Regex.Match(entry.Content, @"(\@.+?)($| )"); //ニコスクリプトをパースしてリストに追加 if (match.Success) { if (NicoScript == null) { NicoScript = new List <NicoScriptBase>(); } var script = NicoNicoNicoScriptInterpreter.GetScriptInstance(this, entry); if (script != null) { NicoScript.Add(script); entry.NicoScript = script; } } } listlist.CommentList.Add(new VideoCommentEntryViewModel(this, entry)); } CommentListList.Add(listlist); } if (CommentListList.Count > 0) { SelectedList = CommentListList.First(); } IsActive = false; CanComment = true; Owner?.Handler?.InvokeScript("CommentViewModel$initialize"); ApplyFontSize(); if (CommentVisibility) { Owner?.Handler?.InvokeScript("CommentViewModel$show_comment"); } else { Owner?.Handler?.InvokeScript("CommentViewModel$hide_comment"); } Initialized = true; }