Rename method, address comments.

Took 5 minutes
This commit is contained in:
Lukas Brübach 2026-08-17 10:06:23 +02:00
parent de2b948533
commit 80a972f90e
4 changed files with 17 additions and 24 deletions

View file

@ -123,13 +123,9 @@ void TabMessage::sendMessage()
sayEdit->clear();
}
void TabMessage::sendInviteMessage(const QString &text)
bool TabMessage::isUserOnline() const
{
if (!userOnline) {
notifyUserOffline();
return;
}
sendPrivateMessage(text);
return userOnline;
}
void TabMessage::messageSent(const Response &response,

View file

@ -64,10 +64,10 @@ public:
void processUserLeft();
void processUserJoined(const ServerInfo_User &_userInfo);
void sendInviteMessage(const QString &text);
[[nodiscard]] bool isUserOnline() const;
void sendPrivateMessage(const QString &text);
private:
void sendPrivateMessage(const QString &text);
bool shouldShowSystemPopup(const Event_UserMessage &event);
void showSystemPopup(const Event_UserMessage &event);
void notifyUserOffline();

View file

@ -68,9 +68,7 @@ TabRoom::TabRoom(TabSupervisor *_tabSupervisor,
userList = userListPanel->getUserList();
connect(userListPanel, &UserListPanelWidget::openMessageDialog, this, &TabRoom::openMessageDialog);
const std::function<QList<GameInviteOption>()> gameInviteLinkProvider = [this]() -> QList<GameInviteOption> {
return tabSupervisor->getGameInviteLinksForRoom(roomId);
};
const auto gameInviteLinkProvider = [this]() { return tabSupervisor->getGameInviteLinksForRoom(roomId); };
userList->setGameInviteLinkProvider(gameInviteLinkProvider);
chatView = new ChatView(tabSupervisor, nullptr, true, this);

View file

@ -961,9 +961,7 @@ QList<GameInviteOption> TabSupervisor::getGameInviteLinksForRoom(int roomId) con
// The inviter may be in several games of the same room (hosting one and
// spectating another, for example). Return every game so the caller can
// let the user choose which one to invite to.
QMapIterator<int, TabGame *> gameIterator(gameTabs);
while (gameIterator.hasNext()) {
TabGame *tab = gameIterator.next().value();
for (TabGame *tab : gameTabs) {
GameMetaInfo *metaInfo = tab->getGame()->getGameMetaInfo();
if (metaInfo->proto().room_id() != roomId) {
continue;
@ -977,14 +975,15 @@ QList<GameInviteOption> TabSupervisor::getGameInviteLinksForRoom(int roomId) con
const int gameId = metaInfo->gameId();
const QString description = QString::fromStdString(metaInfo->proto().description());
GameInviteOption option;
option.gameId = gameId;
option.label =
description.isEmpty() ? tr("Game #%1").arg(gameId) : tr("Game #%1 — %2").arg(gameId).arg(description);
option.url = makeGameJoinLink(client->serverName(), client->serverPort(), roomId, gameId, description);
option.description = description;
option.onlyBuddies = metaInfo->proto().only_buddies();
option.creatorName = QString::fromStdString(metaInfo->proto().creator_info().name());
GameInviteOption option{
.gameId = gameId,
.label =
description.isEmpty() ? tr("Game #%1").arg(gameId) : tr("Game #%1 — %2").arg(gameId).arg(description),
.url = makeGameJoinLink(client->serverName(), client->serverPort(), roomId, gameId, description),
.description = description,
.onlyBuddies = metaInfo->proto().only_buddies(),
.creatorName = QString::fromStdString(metaInfo->proto().creator_info().name()),
};
options.append(option);
}
@ -994,8 +993,8 @@ QList<GameInviteOption> TabSupervisor::getGameInviteLinksForRoom(int roomId) con
void TabSupervisor::sendInviteToUser(const QString &userName, const QString &inviteText)
{
TabMessage *tab = addMessageTab(userName, true);
if (tab) {
tab->sendInviteMessage(inviteText);
if (tab && tab->isUserOnline()) {
tab->sendPrivateMessage(inviteText);
}
}