Choose a local channel when opening a server link

This commit is contained in:
evgeny committed 2026-10-28 11:03:18 +01:00
1 parent 031b8b086b
commit f606c65858
3 files changed
+49

No files matched your search

+17
View File
@@ -14,6 +14,7 @@
#include "dminvitedialog.h"
#include "debug_ui.h"
#include "inviteby.h"
#include <QInputDialog>
#include "joindialog.h"
#include "settingsdialog.h"
#include "channelsettingsdialog.h"
@@ -1156,6 +1157,19 @@ void MainWindow::onMessageLinkActivated(const QString& link) {
"The core is not running.")); return;
}
const QString channelId = QString::number(invite.channelId);
if (invite.kind == INVITE_KIND_SERVER) {
QStringList ids, labels;
for (const auto& channel : m_db->getChannels()) {
if (!m_db->isChannelMember(channel.channelId, m_db->myNodeId())) continue;
ids.append(channel.channelId); labels.append(channel.name + " (" + channel.channelId + ")");
}
bool accepted = false;
const QString selected = QInputDialog::getItem(this, QCoreApplication::translate("ChatGui", "Add server to channel"),
QCoreApplication::translate("ChatGui", "Channel:"), labels, qMax(0, ids.indexOf(m_currentChannelId)), false, &accepted);
int index = labels.indexOf(selected);
if (!accepted || index < 0) return;
InviteByLinkDialog dialog(ids[index], m_node, this, link); dialog.exec(); return;
}
for (const auto& channel : m_db->getChannels()) {
if (channel.channelId == channelId && m_db->isChannelMember(channelId, m_db->myNodeId())) {
GUI_INFO("invite link: opening existing group ch=%s", qPrintable(channelId));
@@ -1322,6 +1336,9 @@ void MainWindow::showJoinDialog() {
autoLink = selText;
}
if (!autoLink.isEmpty() && decodeInviteLink(autoLink).kind == INVITE_KIND_SERVER) {
onMessageLinkActivated(autoLink); return;
}
QPointer<JoinDialog> dialog = new JoinDialog(m_node, m_db, this, autoLink);
auto release = qScopeGuard([&] { delete dialog.data(); }); dialog->exec();
}