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
(cherry picked from commit 0dbb56ba1e)
This commit is contained in:
@@ -133,7 +133,7 @@ Kirigami.OverlaySheet {
|
|||||||
text: i18n("Open a private chat")
|
text: i18n("Open a private chat")
|
||||||
icon.name: "document-send"
|
icon.name: "document-send"
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
Controller.activeConnection.requestDirectChat(user)
|
Controller.openOrCreateDirectChat(user);
|
||||||
root.close()
|
root.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,6 +47,7 @@
|
|||||||
#include "neochatuser.h"
|
#include "neochatuser.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include "roommanager.h"
|
||||||
#include <KStandardShortcut>
|
#include <KStandardShortcut>
|
||||||
|
|
||||||
#ifndef Q_OS_ANDROID
|
#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
|
QString Controller::formatByteSize(double size, int precision) const
|
||||||
{
|
{
|
||||||
return KFormat().formatByteSize(size, precision);
|
return KFormat().formatByteSize(size, precision);
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ class QNetworkConfigurationManager;
|
|||||||
#include "user.h"
|
#include "user.h"
|
||||||
|
|
||||||
class NeoChatRoom;
|
class NeoChatRoom;
|
||||||
|
class NeoChatUser;
|
||||||
class QQuickWindow;
|
class QQuickWindow;
|
||||||
|
|
||||||
using namespace Quotient;
|
using namespace Quotient;
|
||||||
@@ -86,6 +87,8 @@ public:
|
|||||||
|
|
||||||
Q_INVOKABLE QString formatDuration(quint64 msecs, KFormat::DurationFormatOptions options = KFormat::DefaultDuration) const;
|
Q_INVOKABLE QString formatDuration(quint64 msecs, KFormat::DurationFormatOptions options = KFormat::DefaultDuration) const;
|
||||||
Q_INVOKABLE QString formatByteSize(double size, int precision = 1) const;
|
Q_INVOKABLE QString formatByteSize(double size, int precision = 1) const;
|
||||||
|
|
||||||
|
Q_INVOKABLE void openOrCreateDirectChat(NeoChatUser *user);
|
||||||
private:
|
private:
|
||||||
explicit Controller(QObject *parent = nullptr);
|
explicit Controller(QObject *parent = nullptr);
|
||||||
~Controller() override;
|
~Controller() override;
|
||||||
|
|||||||
Reference in New Issue
Block a user