Skip to content

Commit

Permalink
Improving public chat message when service is unavailable
Browse files Browse the repository at this point in the history
  • Loading branch information
elieserdejesus committed Jun 28, 2020
1 parent 34b075d commit 77bfc03
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Common/gui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1708,10 +1708,16 @@ void MainWindow::createMainChat(bool turnedOn)
});

connect(mainChat.data(), &MainChat::error, [=](const QString &errorMessage){
if (mainController) {
Q_UNUSED(errorMessage)

if (mainController && mainChatPanel->isOn()) {
auto localUserName = mainController->getUserName();
auto author = JAMTABA_CHAT_BOT_NAME;
mainChatPanel->addMessage(localUserName, author, errorMessage, true, false);
QString message(tr("Public chat error - service is temporarily unavailable"));
mainChatPanel->addMessage(localUserName, author, message, true, false);
mainChatPanel->turnOff();
mainChatPanel->hideOnOffButton();
mainChatPanel->setDisabled(true);
}
});

Expand Down
5 changes: 5 additions & 0 deletions src/Common/gui/chat/ChatPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ void ChatPanel::turnOff()
toggleOnOff();
}

bool ChatPanel::isOn() const
{
return on;
}

void ChatPanel::toggleOnOff()
{
on = !on;
Expand Down
2 changes: 2 additions & 0 deletions src/Common/gui/chat/ChatPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class ChatPanel : public QWidget
void turnOn();
void turnOff();

bool isOn() const;

static void setFontSizeOffset(qint8 sizeOffset);

public slots:
Expand Down

0 comments on commit 77bfc03

Please sign in to comment.