예제 #1
0
        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");
            }
        }
예제 #2
0
        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;
        }