Fix creating broken direct chat for user with a direct chat already open
Just enter the existing room instead of trying to create a new one but broken. Fix !237
This commit is contained in:
@@ -146,7 +146,7 @@ Kirigami.OverlaySheet {
|
||||
text: i18n("Open a private chat")
|
||||
icon.name: "document-send"
|
||||
onTriggered: {
|
||||
Controller.activeConnection.requestDirectChat(user)
|
||||
Controller.openOrCreateDirectChat(user);
|
||||
root.close()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
#include "neochatuser.h"
|
||||
#include "settings.h"
|
||||
#include "utils.h"
|
||||
#include "roommanager.h"
|
||||
#include <KStandardShortcut>
|
||||
|
||||
#ifndef Q_OS_ANDROID
|
||||
@@ -592,6 +593,17 @@ void Controller::joinRoom(const QString &alias)
|
||||
});
|
||||
}
|
||||
|
||||
void Controller::openOrCreateDirectChat(NeoChatUser *user)
|
||||
{
|
||||
const auto existing = activeConnection()->directChats();
|
||||
|
||||
if (existing.contains(user)) {
|
||||
RoomManager::instance().enterRoom(static_cast<NeoChatRoom *>(activeConnection()->room(existing.value(user))));
|
||||
return;
|
||||
}
|
||||
activeConnection()->requestDirectChat(user);
|
||||
}
|
||||
|
||||
QString Controller::formatByteSize(double size, int precision) const
|
||||
{
|
||||
return KFormat().formatByteSize(size, precision);
|
||||
|
||||
@@ -21,6 +21,7 @@ class QNetworkConfigurationManager;
|
||||
#include "user.h"
|
||||
|
||||
class NeoChatRoom;
|
||||
class NeoChatUser;
|
||||
class QQuickWindow;
|
||||
|
||||
using namespace Quotient;
|
||||
@@ -86,6 +87,8 @@ public:
|
||||
|
||||
Q_INVOKABLE QString formatDuration(quint64 msecs, KFormat::DurationFormatOptions options = KFormat::DefaultDuration) const;
|
||||
Q_INVOKABLE QString formatByteSize(double size, int precision = 1) const;
|
||||
|
||||
Q_INVOKABLE void openOrCreateDirectChat(NeoChatUser *user);
|
||||
private:
|
||||
explicit Controller(QObject *parent = nullptr);
|
||||
~Controller() override;
|
||||
|
||||
Reference in New Issue
Block a user