Example #1
0
        /// <inheritdoc/>
        public async Task CloseOrReopen(ICommentViewModel comment)
        {
            var address = HostAddress.Create(Repository.CloneUrl);

            if (State == PullRequestState.Open)
            {
                await service.CloseIssueish(
                    address,
                    Repository.Owner,
                    Repository.Name,
                    Number).ConfigureAwait(true);

                State = PullRequestState.Closed;
            }
            else
            {
                await service.ReopenIssueish(
                    address,
                    Repository.Owner,
                    Repository.Name,
                    Number).ConfigureAwait(true);

                State = PullRequestState.Open;
            }
        }
 protected virtual CommentDraft BuildDraft(ICommentViewModel comment)
 {
     return(!string.IsNullOrEmpty(comment.Body) ?
            new CommentDraft {
         Body = comment.Body
     } :
            null);
 }
Example #3
0
 /// <summary>
 /// Initializes a placeholder comment that will allow the user to enter a reply, and wires up
 /// event listeners for saving drafts.
 /// </summary>
 /// <param name="placeholder">The placeholder comment view model.</param>
 /// <returns>An object which when disposed will remove the event listeners.</returns>
 protected IDisposable InitializePlaceholder(ICommentViewModel placeholder)
 {
     return(placeholder.WhenAnyValue(
                x => x.EditState,
                x => x.Body,
                (state, body) => (state, body))
            .Subscribe(x => PlaceholderChanged(placeholder, x.state)));
 }
Example #4
0
        public void Whowatch_コメントにニックネームが含まれていたらそれがニックネームにセットされるか()
        {
            var nick = "abc";
            var user = new UserTest("");
            ICommentViewModel cvm = CreateCvm(user, username: nick, message: "@" + nick);

            Assert.AreEqual("abc", ((IMessageText)cvm.NameItems.ToList()[0]).Text);
        }
Example #5
0
 public async Task EditComment(ICommentViewModel comment)
 {
     await service.EditComment(
         HostAddress.Create(Repository.CloneUrl),
         Repository.Owner,
         Repository.Name,
         comment.DatabaseId,
         comment.Body).ConfigureAwait(false);
 }
Example #6
0
        /// <inheritdoc/>
        public async Task PostComment(ICommentViewModel comment)
        {
            var address = HostAddress.Create(Repository.CloneUrl);
            var result  = await service.PostComment(address, Id, comment.Body).ConfigureAwait(true);

            timeline.Remove(comment);
            await AddComment(result).ConfigureAwait(true);
            await AddPlaceholder().ConfigureAwait(true);
        }
Example #7
0
        public async Task DeleteComment(ICommentViewModel comment)
        {
            await service.DeleteComment(
                HostAddress.Create(Repository.CloneUrl),
                Repository.Owner,
                Repository.Name,
                comment.DatabaseId).ConfigureAwait(true);

            timeline.Remove(comment);
        }
Example #8
0
        public void LineLive_コメントにニックネームが含まれていたらそれがニックネームにセットされるか()
        {
            var nick     = "abc";
            var userMock = new Mock <IUser>();

            userMock.SetupGet(u => u.Nickname).Returns(nick);
            ICommentViewModel cvm = CreateCvm(userMock.Object, username: "", message: "@" + nick);

            Assert.AreEqual("abc", ((IMessageText)cvm.NameItems.ToList()[0]).Text);
        }
        public void 既にニックネームが登録されているユーザがコメントをしたらニックネームが反映されるか()
        {
            var nick = "abc";
            var user = new UserTest("")
            {
                Nickname = nick
            };
            ICommentViewModel cvm = CreateCvm(user, username: nick, message: "xyz");

            Assert.AreEqual("abc", ((IMessageText)cvm.NameItems.ToList()[0]).Text);
        }
        protected async Task DeleteDraft(ICommentViewModel comment)
        {
            if (draftThrottles.TryGetValue(comment, out var throttle))
            {
                throttle.OnCompleted();
                draftThrottles.Remove(comment);
            }

            var(key, secondaryKey) = GetDraftKeys(comment);
            await DraftStore.DeleteDraft(key, secondaryKey).ConfigureAwait(false);
        }
        public void コメントにニックネームが含まれていたらそのユーザの他のCVMにも反映されるか()
        {
            var userid = "id";
            var nick   = "nick";
            var user   = new UserTest(userid);

            ICommentViewModel cvm1 = CreateCvm(user, userid: userid, message: "");

            Assert.AreEqual(userid, ((IMessageText)cvm1.NameItems.ToList()[0]).Text);
            ICommentViewModel cvm2 = CreateCvm(user, userid: userid, message: "@" + nick);

            Assert.AreEqual(nick, ((IMessageText)cvm2.NameItems.ToList()[0]).Text);
            Assert.AreEqual(nick, ((IMessageText)cvm1.NameItems.ToList()[0]).Text);
        }
Example #12
0
        public void SetComments(ICommentViewModel comment)
        {
            var pluginCommentData = new CommentData
            {
                Comment  = GetString(comment.MessageItems),
                IsNgUser = false,
                Nickname = GetString(comment.NameItems),
                SiteName = "youtubelive",
            };

            foreach (var plugin in _plugins)
            {
                plugin.OnCommentReceived(pluginCommentData);
            }
        }
 private void AddComment(ICommentViewModel cvm)
 {
     if (cvm is IInfoCommentViewModel info && info.Type > _options.ShowingInfoLevel)
     {
         return;
     }
     if (_isAddingNewCommentTop)
     {
         _comments_old.Insert(0, cvm);
     }
     else
     {
         _comments_old.Add(cvm);
     }
 }
        void UpdateDraft(ICommentViewModel comment)
        {
            if (comment.EditState == CommentEditState.Editing)
            {
                var draft = BuildDraft(comment);
                var(key, secondaryKey) = GetDraftKeys(comment);

                if (draft != null)
                {
                    DraftStore.UpdateDraft(key, secondaryKey, draft).Forget();
                }
                else
                {
                    DraftStore.DeleteDraft(key, secondaryKey).Forget();
                }
            }
        }
Example #15
0
        public void SetComments(ICommentViewModel comment)
        {
            var pluginCommentData = new CommentData
            {
                Comment         = GetString(comment.MessageItems),
                IsNgUser        = false,
                Nickname        = GetString(comment.NameItems),
                ThumbnailUrl    = comment.Thumbnail?.Url,
                ThumbnailWidth  = comment.Thumbnail?.Width ?? 50,
                ThumbnailHeight = comment.Thumbnail?.Height ?? 50,
                Is184           = comment.Is184,
            };

            foreach (var plugin in _plugins)
            {
                plugin.OnCommentReceived(pluginCommentData);
            }
        }
        void PlaceholderChanged(ICommentViewModel placeholder, CommentEditState state)
        {
            if (state == CommentEditState.Editing)
            {
                if (!draftThrottles.TryGetValue(placeholder, out var throttle))
                {
                    var subject = new Subject <ICommentViewModel>();
                    subject.Throttle(TimeSpan.FromSeconds(1), timerScheduler).Subscribe(UpdateDraft);
                    draftThrottles.Add(placeholder, subject);
                    throttle = subject;
                }

                throttle.OnNext(placeholder);
            }
            else if (state != CommentEditState.Editing)
            {
                DeleteDraft(placeholder).Forget();
            }
        }
        public McvCommentViewModel(ICommentViewModel cvm, IConnectionStatus connectionName)
        {
            _cvm = cvm;
            _cvm.PropertyChanged += (s, e) =>
            {
                switch (e.PropertyName)
                {
                case nameof(_cvm.FontFamily):
                    RaisePropertyChanged(nameof(FontFamily));
                    break;

                case nameof(_cvm.FontStyle):
                    RaisePropertyChanged(nameof(FontStyle));
                    break;

                case nameof(_cvm.FontWeight):
                    RaisePropertyChanged(nameof(FontWeight));
                    break;

                case nameof(_cvm.FontSize):
                    RaisePropertyChanged(nameof(FontSize));
                    break;

                case nameof(_cvm.NameItems):
                    RaisePropertyChanged(nameof(NameItems));
                    break;

                case nameof(_cvm.IsVisible):
                    RaisePropertyChanged(nameof(IsVisible));
                    break;
                }
            };
            ConnectionName = connectionName;
            ConnectionName.PropertyChanged += (s, e) =>
            {
                switch (e.PropertyName)
                {
                case nameof(ConnectionName.Name):
                    RaisePropertyChanged(nameof(connectionName));
                    break;
                }
            };
        }
 private void CommentProvider_CommentReceived(object sender, ICommentViewModel e)
 {
     try
     {
         AddComment(e);
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex.Message);
         _logger.LogException(ex);
     }
     //try
     //{
     //    if (IsComment(e.MessageType))
     //    {
     //        _pluginManager.SetComments(e);
     //    }
     //}
     //catch (Exception ex)
     //{
     //    _logger.LogException(ex);
     //}
 }
 public Task PostComment(ICommentViewModel comment) => Task.CompletedTask;
 public override Task EditComment(ICommentViewModel comment) => Task.CompletedTask;
 /// <inheritdoc/>
 public abstract Task DeleteComment(ICommentViewModel comment);
 /// <inheritdoc/>
 public abstract Task EditComment(ICommentViewModel comment);
 protected abstract (string key, string secondaryKey) GetDraftKeys(ICommentViewModel comment);
 protected override (string key, string secondaryKey) GetDraftKeys(ICommentViewModel comment) => ("file.cs", "10");
Example #25
0
 public Class2(ICommentViewModel cvm)
 {
     _cvm = cvm;
 }
 public Task DeleteComment(ICommentViewModel comment) => Task.CompletedTask;
 public Task CloseOrReopen(ICommentViewModel comment) => Task.CompletedTask;