void addNewMessage(bool send = true) { Log.Debug($"addNewMessage {send}"); // This little trick validates any pending auto-correction or auto-spelling just after hitting the 'Send' button TextView.RefreshFirstResponder(); var indexPath = NSIndexPath.FromRowSection(0, 0); var rowAnimation = Inverted ? UITableViewRowAnimation.Bottom : UITableViewRowAnimation.Top; var scrollPosition = Inverted ? UITableViewScrollPosition.Bottom : UITableViewScrollPosition.Top; TableView.BeginUpdates(); if ((send && BotClient.Shared.SendMessage(TextView.Text)) || !send) { TableView.InsertRows(new [] { NSIndexPath.FromRowSection(0, 0) }, rowAnimation); } TableView.EndUpdates(); var message = Messages.FirstOrDefault(); if (message != null) { TypingIndicatorView.RemoveUsername(message.Activity.From.Name); TableView.ScrollToRow(indexPath, scrollPosition, true); } // Fixes the cell from blinking (because of the transform, when using translucent cells) // See https://github.com/slackhq/SlackTextViewController/issues/94#issuecomment-69929927 // TableView.ReloadRows (new [] { indexPath }, UITableViewRowAnimation.Automatic); }
void handleBotClientUserTypingMessageReceived(object sender, string e) { if (!string.IsNullOrEmpty(e)) { TypingIndicatorView.InsertUsername(e); Task.Run(async() => { await Task.Delay(3000); BeginInvokeOnMainThread(() => TypingIndicatorView.RemoveUsername(e)); }); } }