mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-06-22 02:01:08 +07:00
fix: fixed country model update
This commit is contained in:
@@ -33,7 +33,6 @@
|
|||||||
#include "core/controllers/connectionController.h"
|
#include "core/controllers/connectionController.h"
|
||||||
#include "ui/models/clientManagementModel.h"
|
#include "ui/models/clientManagementModel.h"
|
||||||
#include "ui/controllers/api/apiNewsUiController.h"
|
#include "ui/controllers/api/apiNewsUiController.h"
|
||||||
#include "ui/models/api/apiCountryModel.h"
|
|
||||||
#include "ui/models/containersModel.h"
|
#include "ui/models/containersModel.h"
|
||||||
#include "core/utils/containerEnum.h"
|
#include "core/utils/containerEnum.h"
|
||||||
|
|
||||||
@@ -177,16 +176,13 @@ void CoreSignalHandlers::initApiCountryModelUpdateHandler()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonArray availableCountries;
|
|
||||||
QString serverCountryCode;
|
|
||||||
|
|
||||||
const auto apiV2 = m_coreController->m_serversRepository->apiV2Config(processedServerId);
|
const auto apiV2 = m_coreController->m_serversRepository->apiV2Config(processedServerId);
|
||||||
if (apiV2.has_value()) {
|
if (!apiV2.has_value()) {
|
||||||
availableCountries = apiV2->apiConfig.availableCountries;
|
return;
|
||||||
serverCountryCode = apiV2->apiConfig.serverCountryCode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_coreController->m_apiCountryModel->updateModel(availableCountries, serverCountryCode);
|
m_coreController->m_apiCountryModel->updateModel(apiV2->apiConfig.availableCountries,
|
||||||
|
apiV2->apiConfig.serverCountryCode);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -156,7 +156,17 @@ void ServersUiController::updateModel()
|
|||||||
|
|
||||||
m_serversModel->updateModel(m_orderedServerDescriptions, defaultServerId);
|
m_serversModel->updateModel(m_orderedServerDescriptions, defaultServerId);
|
||||||
|
|
||||||
updateContainersModel();
|
if (!m_processedServerId.isEmpty()) {
|
||||||
|
if (isServerFromApi(m_processedServerId)) {
|
||||||
|
const auto &description = serverDescriptionById(m_processedServerId);
|
||||||
|
if (description.isApiV2 && description.isCountrySelectionAvailable
|
||||||
|
&& !description.apiAvailableCountries.isEmpty()) {
|
||||||
|
emit updateApiCountryModel();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
updateContainersModel();
|
||||||
|
}
|
||||||
|
}
|
||||||
updateDefaultServerContainersModel();
|
updateDefaultServerContainersModel();
|
||||||
|
|
||||||
if (hadServersFromGatewayBefore != hasServersFromGatewayNow) {
|
if (hadServersFromGatewayBefore != hasServersFromGatewayNow) {
|
||||||
@@ -350,19 +360,14 @@ void ServersUiController::setProcessedServerId(const QString &serverId)
|
|||||||
m_processedServerId = normalizedServerId;
|
m_processedServerId = normalizedServerId;
|
||||||
|
|
||||||
if (newIndex >= 0) {
|
if (newIndex >= 0) {
|
||||||
updateContainersModel();
|
if (isServerFromApi(m_processedServerId)) {
|
||||||
|
const auto &description = serverDescriptionById(m_processedServerId);
|
||||||
for (const auto &description : m_orderedServerDescriptions) {
|
if (description.isApiV2 && description.isCountrySelectionAvailable
|
||||||
if (description.serverId != normalizedServerId) {
|
&& !description.apiAvailableCountries.isEmpty()) {
|
||||||
continue;
|
emit updateApiCountryModel();
|
||||||
}
|
}
|
||||||
if (description.isApiV2) {
|
} else {
|
||||||
if (description.isCountrySelectionAvailable && !description.apiAvailableCountries.isEmpty()) {
|
updateContainersModel();
|
||||||
emit updateApiCountryModel();
|
|
||||||
}
|
|
||||||
emit updateApiServicesModel();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -113,7 +113,6 @@ signals:
|
|||||||
void processedContainerIndexChanged(int index);
|
void processedContainerIndexChanged(int index);
|
||||||
void hasServersFromGatewayApiChanged();
|
void hasServersFromGatewayApiChanged();
|
||||||
void updateApiCountryModel();
|
void updateApiCountryModel();
|
||||||
void updateApiServicesModel();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void updateModel();
|
void updateModel();
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ PageType {
|
|||||||
|
|
||||||
model: ApiCountryModel
|
model: ApiCountryModel
|
||||||
|
|
||||||
currentIndex: 0
|
currentIndex: ApiCountryModel.currentIndex
|
||||||
|
|
||||||
ButtonGroup {
|
ButtonGroup {
|
||||||
id: containersRadioButtonGroup
|
id: containersRadioButtonGroup
|
||||||
|
|||||||
Reference in New Issue
Block a user