doovers for failed messages, some corner cases fixes with handling errors during message sending

This commit is contained in:
Blue 2021-05-23 01:03:14 +03:00
parent ddfaa63a24
commit 3f1fba4de2
Signed by untrusted user: blue
GPG key ID: 9B203B252A63EE38
12 changed files with 89 additions and 19 deletions

View file

@ -466,6 +466,15 @@ void Squawk::onConversationMessage(const Shared::Message& msg)
emit sendMessage(acc, msg);
}
void Squawk::onConversationResend(const QString& id)
{
Conversation* conv = static_cast<Conversation*>(sender());
QString acc = conv->getAccount();
QString jid = conv->getJid();
emit resendMessage(acc, jid, id);
}
void Squawk::onRequestArchive(const QString& account, const QString& jid, const QString& before)
{
emit requestArchive(account, jid, 20, before); //TODO amount as a settings value
@ -914,6 +923,7 @@ void Squawk::subscribeConversation(Conversation* conv)
{
connect(conv, &Conversation::destroyed, this, &Squawk::onConversationClosed);
connect(conv, &Conversation::sendMessage, this, &Squawk::onConversationMessage);
connect(conv, &Conversation::resendMessage, this, &Squawk::onConversationResend);
connect(conv, &Conversation::notifyableMessage, this, &Squawk::notify);
}

View file

@ -63,6 +63,7 @@ signals:
void disconnectAccount(const QString&);
void changeState(Shared::Availability state);
void sendMessage(const QString& account, const Shared::Message& data);
void resendMessage(const QString& account, const QString& jid, const QString& id);
void requestArchive(const QString& account, const QString& jid, int count, const QString& before);
void subscribeContact(const QString& account, const QString& jid, const QString& reason);
void unsubscribeContact(const QString& account, const QString& jid, const QString& reason);
@ -148,6 +149,7 @@ private slots:
void onComboboxActivated(int index);
void onRosterItemDoubleClicked(const QModelIndex& item);
void onConversationMessage(const Shared::Message& msg);
void onConversationResend(const QString& id);
void onRequestArchive(const QString& account, const QString& jid, const QString& before);
void onRosterContextMenu(const QPoint& point);
void onItemCollepsed(const QModelIndex& index);

View file

@ -414,6 +414,16 @@ void Conversation::onFeedContext(const QPoint& pos)
contextMenu->clear();
bool showMenu = false;
if (item->getState() == Shared::Message::State::error) {
showMenu = true;
QString id = item->getId();
QAction* resend = contextMenu->addAction(Shared::icon("view-refresh"), tr("Try sending again"));
connect(resend, &QAction::triggered, [this, id]() {
element->feed->registerUpload(id);
emit resendMessage(id);
});
}
QString path = item->getAttachPath();
if (path.size() > 0) {
showMenu = true;

View file

@ -80,6 +80,7 @@ public:
signals:
void sendMessage(const Shared::Message& message);
void resendMessage(const QString& id);
void requestArchive(const QString& before);
void shown();
void requestLocalFile(const QString& messageId, const QString& url);