feature: added error messages handler

This commit is contained in:
vladimir.kuznetsov 2025-02-19 20:27:15 +07:00
parent a5254ac238
commit eda24765e7
4 changed files with 16 additions and 17 deletions

View file

@ -196,10 +196,11 @@ void CoreController::initAppleController()
void CoreController::initSignalHandlers() void CoreController::initSignalHandlers()
{ {
initErrorMessagesHandler();
initApiCountryModelUpdateHandler(); initApiCountryModelUpdateHandler();
initContainerModelUpdateHandler(); initContainerModelUpdateHandler();
initAdminConfigRevokedHandler(); initAdminConfigRevokedHandler();
initConnectionErrorOccurredHandler();
initPassphraseRequestHandler(); initPassphraseRequestHandler();
initTranslationsUpdatedHandler(); initTranslationsUpdatedHandler();
initAutoConnectHandler(); initAutoConnectHandler();
@ -244,6 +245,17 @@ void CoreController::updateTranslator(const QLocale &locale)
emit translationsUpdated(); emit translationsUpdated();
} }
void CoreController::initErrorMessagesHandler()
{
connect(m_connectionController.get(), &ConnectionController::connectionErrorOccurred, this, [this](ErrorCode errorCode) {
emit m_pageController->showErrorMessage(errorCode);
emit m_vpnConnection->connectionStateChanged(Vpn::ConnectionState::Disconnected);
});
connect(m_apiConfigsController.get(), &ApiConfigsController::errorOccurred, m_pageController.get(),
qOverload<ErrorCode>(&PageController::showErrorMessage));
}
void CoreController::setQmlRoot() void CoreController::setQmlRoot()
{ {
m_systemController->setQmlRoot(m_engine->rootObjects().value(0)); m_systemController->setQmlRoot(m_engine->rootObjects().value(0));
@ -274,14 +286,6 @@ void CoreController::initAdminConfigRevokedHandler()
&ServersModel::clearCachedProfile); &ServersModel::clearCachedProfile);
} }
void CoreController::initConnectionErrorOccurredHandler()
{
connect(m_connectionController.get(), &ConnectionController::connectionErrorOccurred, this, [this](ErrorCode errorCode) {
emit m_pageController->showErrorMessage(errorCode);
emit m_vpnConnection->connectionStateChanged(Vpn::ConnectionState::Disconnected);
});
}
void CoreController::initPassphraseRequestHandler() void CoreController::initPassphraseRequestHandler()
{ {
connect(m_installController.get(), &InstallController::passphraseRequestStarted, m_pageController.get(), connect(m_installController.get(), &InstallController::passphraseRequestStarted, m_pageController.get(),

View file

@ -69,10 +69,11 @@ private:
void updateTranslator(const QLocale &locale); void updateTranslator(const QLocale &locale);
void initErrorMessagesHandler();
void initApiCountryModelUpdateHandler(); void initApiCountryModelUpdateHandler();
void initContainerModelUpdateHandler(); void initContainerModelUpdateHandler();
void initAdminConfigRevokedHandler(); void initAdminConfigRevokedHandler();
void initConnectionErrorOccurredHandler();
void initPassphraseRequestHandler(); void initPassphraseRequestHandler();
void initTranslationsUpdatedHandler(); void initTranslationsUpdatedHandler();
void initAutoConnectHandler(); void initAutoConnectHandler();

View file

@ -139,6 +139,7 @@ PageType {
if (!ApiConfigsController.updateServiceFromGateway(ServersModel.defaultIndex, countryCode, countryName)) { if (!ApiConfigsController.updateServiceFromGateway(ServersModel.defaultIndex, countryCode, countryName)) {
ApiCountryModel.currentIndex = prevIndex ApiCountryModel.currentIndex = prevIndex
} }
PageController.showBusyIndicator(false)
} }
} }

View file

@ -212,12 +212,7 @@ PageType {
Connections { Connections {
target: ApiConfigsController target: ApiConfigsController
function onErrorOccurred(error) {
PageController.showErrorMessage(error)
}
function onInstallServerFromApiFinished(message) { function onInstallServerFromApiFinished(message) {
PageController.showBusyIndicator(false)
if (!ConnectionController.isConnected) { if (!ConnectionController.isConnected) {
ServersModel.setDefaultServerIndex(ServersModel.getServersCount() - 1); ServersModel.setDefaultServerIndex(ServersModel.getServersCount() - 1);
ServersModel.processedIndex = ServersModel.defaultIndex ServersModel.processedIndex = ServersModel.defaultIndex
@ -228,8 +223,6 @@ PageType {
} }
function onChangeApiCountryFinished(message) { function onChangeApiCountryFinished(message) {
PageController.showBusyIndicator(false)
PageController.goToPageHome() PageController.goToPageHome()
PageController.showNotificationMessage(message) PageController.showNotificationMessage(message)
} }