fix: refresh session list on rename via reply callback and signal
This commit is contained in:
parent
3b42c9ee25
commit
5ad224dfae
|
|
@ -44,6 +44,8 @@ OllieDBusClient::OllieDBusClient(QObject *parent)
|
||||||
this, SLOT(onSessionCreated(QString)));
|
this, SLOT(onSessionCreated(QString)));
|
||||||
bus.connect(SERVICE, OBJ_PATH, IFACE, "SessionKilled",
|
bus.connect(SERVICE, OBJ_PATH, IFACE, "SessionKilled",
|
||||||
this, SLOT(onSessionKilled(QString)));
|
this, SLOT(onSessionKilled(QString)));
|
||||||
|
bus.connect(SERVICE, OBJ_PATH, IFACE, "SessionRenamed",
|
||||||
|
this, SLOT(onSessionRenamed(QString,QString)));
|
||||||
bus.connect(SERVICE, OBJ_PATH, IFACE, "StateChanged",
|
bus.connect(SERVICE, OBJ_PATH, IFACE, "StateChanged",
|
||||||
this, SLOT(onStateChanged(QString,QString)));
|
this, SLOT(onStateChanged(QString,QString)));
|
||||||
bus.connect(SERVICE, OBJ_PATH, IFACE, "ChatUpdated",
|
bus.connect(SERVICE, OBJ_PATH, IFACE, "ChatUpdated",
|
||||||
|
|
@ -244,11 +246,18 @@ bool OllieDBusClient::killSession(const QString &sessionId)
|
||||||
|
|
||||||
bool OllieDBusClient::renameSession(const QString &sessionId, const QString &newName)
|
bool OllieDBusClient::renameSession(const QString &sessionId, const QString &newName)
|
||||||
{
|
{
|
||||||
if (sessionId == m_activeSessionId) {
|
QDBusPendingCall pending = m_iface->asyncCall("RenameSession", sessionId, newName);
|
||||||
m_activeSessionId = newName;
|
auto *watcher = new QDBusPendingCallWatcher(pending, this);
|
||||||
emit activeSessionIdChanged();
|
connect(watcher, &QDBusPendingCallWatcher::finished, this, [this, sessionId, newName](QDBusPendingCallWatcher *w) {
|
||||||
}
|
w->deleteLater();
|
||||||
m_iface->asyncCall("RenameSession", sessionId, newName);
|
QDBusPendingReply<bool> reply = *w;
|
||||||
|
if (reply.isError() || !reply.value()) return;
|
||||||
|
if (m_activeSessionId == sessionId) {
|
||||||
|
m_activeSessionId = newName;
|
||||||
|
emit activeSessionIdChanged();
|
||||||
|
}
|
||||||
|
refreshSessions();
|
||||||
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -288,6 +297,15 @@ void OllieDBusClient::onSessionKilled(const QString &session_id)
|
||||||
refreshSessions();
|
refreshSessions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OllieDBusClient::onSessionRenamed(const QString &old_id, const QString &new_id)
|
||||||
|
{
|
||||||
|
if (m_activeSessionId == old_id) {
|
||||||
|
m_activeSessionId = new_id;
|
||||||
|
emit activeSessionIdChanged();
|
||||||
|
}
|
||||||
|
refreshSessions();
|
||||||
|
}
|
||||||
|
|
||||||
void OllieDBusClient::onStateChanged(const QString &session_id, const QString &new_state)
|
void OllieDBusClient::onStateChanged(const QString &session_id, const QString &new_state)
|
||||||
{
|
{
|
||||||
if (session_id == m_activeSessionId) {
|
if (session_id == m_activeSessionId) {
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,7 @@ signals:
|
||||||
private slots:
|
private slots:
|
||||||
void onSessionCreated(const QString &session_id);
|
void onSessionCreated(const QString &session_id);
|
||||||
void onSessionKilled(const QString &session_id);
|
void onSessionKilled(const QString &session_id);
|
||||||
|
void onSessionRenamed(const QString &old_id, const QString &new_id);
|
||||||
void onStateChanged(const QString &session_id, const QString &new_state);
|
void onStateChanged(const QString &session_id, const QString &new_state);
|
||||||
void onChatUpdated(const QString &session_id, qlonglong offset, const QString &new_text);
|
void onChatUpdated(const QString &session_id, qlonglong offset, const QString &new_text);
|
||||||
|
|
||||||
|
|
|
||||||
Reference in New Issue