mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-05-08 14:33:23 +00:00
update: editServerWithData
This commit is contained in:
@@ -133,7 +133,7 @@ bool ImportController::importLink(const QUrl &url)
|
||||
for (auto it = m_config.begin(); it != m_config.end(); ++it) {
|
||||
serverConfig.insert(it.key(), it.value());
|
||||
}
|
||||
// TODO: proper name instead of XRaySubLink Test
|
||||
|
||||
serverConfig.insert(config_key::description, m_settings->nextAvailableServerName());
|
||||
serverConfig.insert("xray_subscription_config", configsArray);
|
||||
serverConfig.insert("xray_subscription_config_current", 0);
|
||||
@@ -143,8 +143,7 @@ bool ImportController::importLink(const QUrl &url)
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO: remove configIndex and fix bug with "xray_subscription_config_current" value saving
|
||||
bool ImportController::editServerConfigWithData(QString data, int serverIndex, int configIndex)
|
||||
bool ImportController::editServerConfigWithData(QString data, int serverIndex)
|
||||
{
|
||||
m_maliciousWarningText.clear();
|
||||
|
||||
@@ -158,7 +157,7 @@ bool ImportController::editServerConfigWithData(QString data, int serverIndex, i
|
||||
}
|
||||
serverConfig.insert(config_key::description, serverCurrentConfig.value(config_key::description));
|
||||
serverConfig.insert("xray_subscription_config", serverCurrentConfig.value("xray_subscription_config"));
|
||||
serverConfig.insert("xray_subscription_config_current", configIndex);
|
||||
serverConfig.insert("xray_subscription_config_current", m_serversModel->getCurrentConfigIndex());
|
||||
|
||||
m_serversModel->editServer(serverConfig, serverIndex);
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ public slots:
|
||||
bool importLink(const QUrl &url);
|
||||
bool isValidBase64(const QByteArray &input);
|
||||
QByteArray base64Decode(const QByteArray &input);
|
||||
bool editServerConfigWithData(QString data, int serverIndex, int configIndex);
|
||||
bool editServerConfigWithData(QString data, int serverIndex);
|
||||
bool extractConfigFromFile(const QString &fileName);
|
||||
bool extractConfigFromData(QString data);
|
||||
bool extractConfigFromQr(const QByteArray &data);
|
||||
|
||||
@@ -343,16 +343,17 @@ const ServerCredentials ServersModel::getServerCredentials(const int index)
|
||||
return serverCredentials(index);
|
||||
}
|
||||
|
||||
int ServersModel::getCurrentConfigIndex()
|
||||
const int ServersModel::getCurrentConfigIndex()
|
||||
{
|
||||
const QJsonObject server = m_servers.at(m_defaultServerIndex).toObject();
|
||||
return server.value(configKey::xraySubscriptionConfigCurrent).toInt();
|
||||
}
|
||||
|
||||
void ServersModel::setCurrentConfigIndex(const int &index)
|
||||
void ServersModel::setCurrentConfigIndex(const int index)
|
||||
{
|
||||
QJsonObject server = m_servers.at(m_defaultServerIndex).toObject();
|
||||
server.insert(configKey::xraySubscriptionConfigCurrent, index);
|
||||
m_servers[m_defaultServerIndex] = server;
|
||||
}
|
||||
|
||||
const QString ServersModel::getConfigName(const int &index)
|
||||
|
||||
@@ -120,8 +120,8 @@ public slots:
|
||||
const ServerCredentials getProcessedServerCredentials();
|
||||
const ServerCredentials getServerCredentials(const int index);
|
||||
|
||||
int getCurrentConfigIndex();
|
||||
void setCurrentConfigIndex(const int &index);
|
||||
const int getCurrentConfigIndex();
|
||||
void setCurrentConfigIndex(const int index);
|
||||
const QString getConfigName(const int &index);
|
||||
const QJsonArray getConfigNames();
|
||||
const QString getConfigString(const int &index);
|
||||
|
||||
@@ -124,7 +124,7 @@ PageType {
|
||||
if (index !== ServersModel.getCurrentConfigIndex()) {
|
||||
PageController.showBusyIndicator(true)
|
||||
ServersModel.setCurrentConfigIndex(index)
|
||||
ImportController.editServerConfigWithData(ServersModel.getConfigString(index), ServersModel.getProcessedServerIndex(), index)
|
||||
ImportController.editServerConfigWithData(ServersModel.getConfigString(index), ServersModel.getProcessedServerIndex())
|
||||
PageController.showBusyIndicator(false)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user