[Changelog]: Re-order urls
This commit is contained in:
parent
cab16650b0
commit
9b903f64e4
@ -7,44 +7,44 @@ namespace Components
|
|||||||
|
|
||||||
void Changelog::LoadChangelog()
|
void Changelog::LoadChangelog()
|
||||||
{
|
{
|
||||||
//if (!Changelog::Lines.empty())
|
std::lock_guard _(Mutex);
|
||||||
// return;
|
Lines.clear();
|
||||||
|
|
||||||
std::lock_guard<std::mutex> _(Changelog::Mutex);
|
const auto data = Utils::Cache::GetFile("/develop/CHANGELOG.md");
|
||||||
Changelog::Lines.clear();
|
|
||||||
std::string data = Utils::Cache::GetFile("/develop/CHANGELOG.md");
|
|
||||||
|
|
||||||
if (data.empty())
|
if (data.empty())
|
||||||
{
|
{
|
||||||
data = "^1Unable to get changelog.";
|
Lines.emplace_back("^1Unable to get changelog.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Changelog::Lines = Utils::String::Split(data, '\n');
|
auto buffer = Utils::String::Split(data, '\n');
|
||||||
|
for (auto& line : buffer)
|
||||||
for (auto& line : Changelog::Lines)
|
|
||||||
{
|
{
|
||||||
Utils::String::Replace(line, "\r", "");
|
Utils::String::Replace(line, "\r", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Lines = buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int Changelog::GetChangelogCount()
|
unsigned int Changelog::GetChangelogCount()
|
||||||
{
|
{
|
||||||
return Changelog::Lines.size();
|
return Lines.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Omit column here
|
// Omit column here
|
||||||
const char* Changelog::GetChangelogText(unsigned int item, int /*column*/)
|
const char* Changelog::GetChangelogText(unsigned int item, [[maybe_unused]] int column)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> _(Changelog::Mutex);
|
std::lock_guard _(Mutex);
|
||||||
if (item < Changelog::Lines.size())
|
if (item < Lines.size())
|
||||||
{
|
{
|
||||||
return Utils::String::VA("%s", Changelog::Lines[item].data());
|
return Utils::String::VA("%s", Lines[item].data());
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
void Changelog::SelectChangelog(unsigned int /*index*/)
|
void Changelog::SelectChangelog([[maybe_unused]] unsigned int index)
|
||||||
{
|
{
|
||||||
// Don't do anything in here
|
// Don't do anything in here
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,8 @@ namespace Utils
|
|||||||
{
|
{
|
||||||
const char* Cache::Urls[] =
|
const char* Cache::Urls[] =
|
||||||
{
|
{
|
||||||
|
"https://raw.githubusercontent.com/XLabsProject/iw4x-client",
|
||||||
"https://xlabs.dev",
|
"https://xlabs.dev",
|
||||||
"https://raw.githubusercontent.com/XLabsProject/iw4x-client"
|
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string Cache::ValidUrl;
|
std::string Cache::ValidUrl;
|
||||||
@ -13,7 +13,7 @@ namespace Utils
|
|||||||
|
|
||||||
std::string Cache::GetStaticUrl(const std::string& path)
|
std::string Cache::GetStaticUrl(const std::string& path)
|
||||||
{
|
{
|
||||||
return Cache::Urls[0] + path;
|
return Urls[0] + path;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Cache::GetUrl(const std::string& url, const std::string& path)
|
std::string Cache::GetUrl(const std::string& url, const std::string& path)
|
||||||
@ -23,29 +23,27 @@ namespace Utils
|
|||||||
|
|
||||||
std::string Cache::GetFile(const std::string& path, int timeout, const std::string& useragent)
|
std::string Cache::GetFile(const std::string& path, int timeout, const std::string& useragent)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> _(Cache::CacheMutex);
|
std::lock_guard _(CacheMutex);
|
||||||
|
|
||||||
if (Cache::ValidUrl.empty())
|
if (ValidUrl.empty())
|
||||||
{
|
{
|
||||||
InternetSetCookieA("https://onion.casa", "disclaimer_accepted", "1");
|
InternetSetCookieA("https://onion.casa", "disclaimer_accepted", "1");
|
||||||
InternetSetCookieA("https://hiddenservice.net", "disclaimer_accepted", "1");
|
InternetSetCookieA("https://hiddenservice.net", "disclaimer_accepted", "1");
|
||||||
|
|
||||||
for (int i = 0; i < ARRAYSIZE(Cache::Urls); ++i)
|
for (std::size_t i = 0; i < ARRAYSIZE(Urls); ++i)
|
||||||
{
|
{
|
||||||
std::string result = Utils::WebIO(useragent, Cache::GetUrl(Cache::Urls[i], path)).setTimeout(timeout)->get();
|
std::string result = WebIO(useragent, GetUrl(Urls[i], path)).setTimeout(timeout)->get();
|
||||||
|
|
||||||
if (!result.empty())
|
if (!result.empty())
|
||||||
{
|
{
|
||||||
Cache::ValidUrl = Cache::Urls[i];
|
ValidUrl = Urls[i];
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return {};
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Utils::WebIO(useragent, Cache::GetUrl(Cache::ValidUrl, path)).setTimeout(timeout)->get();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return WebIO(useragent, GetUrl(ValidUrl, path)).setTimeout(timeout)->get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user