Improve reply popup after thread update (#4923)

Co-authored-by: nerix <nero.9@hotmail.de>
Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
iProdigy
2023-11-05 08:25:26 -08:00
committed by GitHub
parent 9dd83b040b
commit 5209e47df1
12 changed files with 177 additions and 59 deletions
+21 -7
View File
@@ -359,7 +359,7 @@ QString SplitInput::handleSendMessage(std::vector<QString> &arguments)
if (this->enableInlineReplying_)
{
// Remove @username prefix that is inserted when doing inline replies
message.remove(0, this->replyThread_->root()->displayName.length() +
message.remove(0, this->replyThread_->displayName.length() +
1); // remove "@username"
if (!message.isEmpty() && message.at(0) == ' ')
@@ -373,7 +373,7 @@ QString SplitInput::handleSendMessage(std::vector<QString> &arguments)
getApp()->commands->execCommand(message, c, false);
// Reply within TwitchChannel
tc->sendReply(sendMessage, this->replyThread_->rootId());
tc->sendReply(sendMessage, this->replyThread_->id);
this->postMessageSend(message, arguments);
return "";
@@ -992,7 +992,7 @@ void SplitInput::editTextChanged()
// We need to verify that
// 1. the @username prefix exists and
// 2. if a character exists after the @username, it is a space
QString replyPrefix = "@" + this->replyThread_->root()->displayName;
QString replyPrefix = "@" + this->replyThread_->displayName;
if (!text.startsWith(replyPrefix) ||
(text.length() > replyPrefix.length() &&
text.at(replyPrefix.length()) != ' '))
@@ -1065,15 +1065,29 @@ void SplitInput::giveFocus(Qt::FocusReason reason)
this->ui_.textEdit->setFocus(reason);
}
void SplitInput::setReply(std::shared_ptr<MessageThread> reply,
bool showReplyingLabel)
void SplitInput::setReply(MessagePtr reply, bool showReplyingLabel)
{
auto oldParent = this->replyThread_;
if (this->enableInlineReplying_ && oldParent)
{
// Remove old reply prefix
auto replyPrefix = "@" + oldParent->displayName;
auto plainText = this->ui_.textEdit->toPlainText().trimmed();
if (plainText.startsWith(replyPrefix))
{
plainText.remove(0, replyPrefix.length());
}
this->ui_.textEdit->setPlainText(plainText.trimmed());
this->ui_.textEdit->moveCursor(QTextCursor::EndOfBlock);
this->ui_.textEdit->resetCompletion();
}
this->replyThread_ = std::move(reply);
if (this->enableInlineReplying_)
{
// Only enable reply label if inline replying
auto replyPrefix = "@" + this->replyThread_->root()->displayName;
auto replyPrefix = "@" + this->replyThread_->displayName;
auto plainText = this->ui_.textEdit->toPlainText().trimmed();
if (!plainText.startsWith(replyPrefix))
{
@@ -1086,7 +1100,7 @@ void SplitInput::setReply(std::shared_ptr<MessageThread> reply,
this->ui_.textEdit->resetCompletion();
}
this->ui_.replyLabel->setText("Replying to @" +
this->replyThread_->root()->displayName);
this->replyThread_->displayName);
}
}