// if preformance would be critical, replace with QHash<QString userId, ChatPageWidget*>
ChatPageWidget* PagesWidget::widget(const QString& userId) const
{
    for (int i = 0; i < count(); i ++) {
        ChatPageWidget* chatPage = dynamic_cast<ChatPageWidget*>(QStackedWidget::widget(i));
        if (chatPage != nullptr && chatPage->getUserId() == userId) {
            return chatPage;
        }
    }
    return nullptr;
}
void PagesWidget::onMessageSent(const QString &message)
{
    ChatPageWidget* chatPage = static_cast<ChatPageWidget*>(sender());
    emit messageSent(chatPage->getUserId(), message);
}