Remember active connection instead of loading first connection
Fix #122
This commit is contained in:
@@ -20,6 +20,9 @@ Kirigami.ScrollablePage {
|
|||||||
delegate: Kirigami.SwipeListItem {
|
delegate: Kirigami.SwipeListItem {
|
||||||
leftPadding: 0
|
leftPadding: 0
|
||||||
rightPadding: 0
|
rightPadding: 0
|
||||||
|
action: Kirigami.Action {
|
||||||
|
onTriggered: Controller.activeConnection = model.connection
|
||||||
|
}
|
||||||
Kirigami.BasicListItem {
|
Kirigami.BasicListItem {
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
|
|||||||
@@ -44,6 +44,7 @@
|
|||||||
#include "events/roommessageevent.h"
|
#include "events/roommessageevent.h"
|
||||||
#include "neochatroom.h"
|
#include "neochatroom.h"
|
||||||
#include "neochatuser.h"
|
#include "neochatuser.h"
|
||||||
|
#include "neochatconfig.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include <KStandardShortcut>
|
#include <KStandardShortcut>
|
||||||
@@ -277,9 +278,16 @@ void Controller::invokeLogin()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!m_connections.isEmpty()) {
|
if (!m_connections.isEmpty()) {
|
||||||
|
const QString id = NeoChatConfig::self()->activeConnection();
|
||||||
|
for (auto *connection : qAsConst(m_connections)) {
|
||||||
|
if (connection->userId() == id) {
|
||||||
|
setActiveConnection(connection);
|
||||||
|
Q_EMIT initiated();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
setActiveConnection(m_connections[0]);
|
setActiveConnection(m_connections[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_EMIT initiated();
|
Q_EMIT initiated();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -542,6 +550,12 @@ void Controller::setActiveConnection(Connection *connection)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_connection = connection;
|
m_connection = connection;
|
||||||
|
if (connection != nullptr) {
|
||||||
|
NeoChatConfig::self()->setActiveConnection(connection->userId());
|
||||||
|
} else {
|
||||||
|
NeoChatConfig::self()->setActiveConnection(QString());
|
||||||
|
}
|
||||||
|
NeoChatConfig::self()->save();
|
||||||
Q_EMIT activeConnectionChanged();
|
Q_EMIT activeConnectionChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,9 @@
|
|||||||
<entry name="OpenRoom" type="String">
|
<entry name="OpenRoom" type="String">
|
||||||
<label>Latest opened room</label>
|
<label>Latest opened room</label>
|
||||||
</entry>
|
</entry>
|
||||||
|
<entry name="ActiveConnection" type="String">
|
||||||
|
<label>Latest active connection</label>
|
||||||
|
</entry>
|
||||||
<entry name="ShowNotifications" type="bool">
|
<entry name="ShowNotifications" type="bool">
|
||||||
<label>Show notifications</label>
|
<label>Show notifications</label>
|
||||||
<default>true</default>
|
<default>true</default>
|
||||||
|
|||||||
Reference in New Issue
Block a user