Don't block UI while executing long runnig actions
Some checks failed
debian-build / build (push) Has been cancelled
Push to master / Check Formatting 🔍 (push) Has been cancelled
Push to master / Build Project 🧱 (push) Has been cancelled
Push to master / Create Release 🛫 (push) Has been cancelled

The previous approach had the problem of losing any action internal
state changes in the created copy.

Revert "Fix temp var values of actions not being accessible"
This reverts commit df42538319.
Revert "Don't block UI while running actions"
This reverts commit a01d26e25d.
This commit is contained in:
WarmUpTill
2026-04-04 19:05:37 +02:00
committed by WarmUpTill
parent 38513735dd
commit ba38b8bf27
13 changed files with 102 additions and 68 deletions

View File

@@ -112,48 +112,56 @@ static URLInfo getURLInfo(const std::string &input, bool keepParams)
bool MacroActionHttp::PerformAction()
{
// Capture all config while holding the segment lock
const auto [host, path] = getURLInfo(_url, !_setParams);
httplib::Client cli(host);
setTimeout(cli, _timeout);
const auto params = _setParams ? getParams(_params) : httplib::Params();
const auto headers = _setHeaders ? getHeaders(_headers)
: httplib::Headers();
const auto method = _method;
const std::string body = _body;
const std::string contentType = _contentType;
// Release the segment lock for the blocking network call
httplib::Result response;
switch (_method) {
case MacroActionHttp::Method::GET:
response = cli.Get(path, params, headers);
break;
case MacroActionHttp::Method::POST: {
const auto pathWithParam =
httplib::append_query_params(path, params);
response =
cli.Post(pathWithParam, headers, _body, _contentType);
break;
}
case MacroActionHttp::Method::PUT: {
const auto pathWithParam =
httplib::append_query_params(path, params);
response = cli.Put(pathWithParam, headers, _body, _contentType);
break;
}
case MacroActionHttp::Method::PATCH: {
const auto pathWithParam =
httplib::append_query_params(path, params);
response =
cli.Patch(pathWithParam, headers, _body, _contentType);
break;
}
case MacroActionHttp::Method::DELETE: {
const auto pathWithParam =
httplib::append_query_params(path, params);
response =
cli.Delete(pathWithParam, headers, _body, _contentType);
break;
}
default:
break;
{
SuspendLock suspendLock(*this);
switch (method) {
case MacroActionHttp::Method::GET:
response = cli.Get(path, params, headers);
break;
case MacroActionHttp::Method::POST: {
const auto pathWithParam =
httplib::append_query_params(path, params);
response = cli.Post(pathWithParam, headers, body,
contentType);
break;
}
case MacroActionHttp::Method::PUT: {
const auto pathWithParam =
httplib::append_query_params(path, params);
response = cli.Put(pathWithParam, headers, body,
contentType);
break;
}
case MacroActionHttp::Method::PATCH: {
const auto pathWithParam =
httplib::append_query_params(path, params);
response = cli.Patch(pathWithParam, headers, body,
contentType);
break;
}
case MacroActionHttp::Method::DELETE: {
const auto pathWithParam =
httplib::append_query_params(path, params);
response = cli.Delete(pathWithParam, headers, body,
contentType);
break;
}
default:
break;
}
}
if (VerboseLoggingEnabled() && !response) {