fix: force load services from cdn on reload list

This commit is contained in:
Andras Bacsai 2024-05-27 10:27:18 +02:00
parent 8bca988520
commit a6a0cb928a
2 changed files with 18 additions and 19 deletions

View File

@ -91,7 +91,7 @@ class Select extends Component
}); });
} else { } else {
$this->search = null; $this->search = null;
$this->allServices = get_service_templates(); $this->allServices = get_service_templates($force);
$this->services = $this->allServices->filter(function ($service, $key) { $this->services = $this->allServices->filter(function ($service, $key) {
return str_contains(strtolower($key), strtolower($this->search)); return str_contains(strtolower($key), strtolower($this->search));
}); });

View File

@ -465,25 +465,24 @@ function sslip(Server $server)
return "http://{$server->ip}.sslip.io"; return "http://{$server->ip}.sslip.io";
} }
function get_service_templates() function get_service_templates(bool $force = false): Collection
{ {
// if (isDev()) { if ($force) {
// $services = File::get(base_path('templates/service-templates.json')); try {
// $services = collect(json_decode($services))->sortKeys(); $response = Http::retry(3, 50)->get(config('constants.services.official'));
// } else { if ($response->failed()) {
// try { return collect([]);
// $response = Http::retry(3, 50)->get(config('constants.services.official')); }
// if ($response->failed()) { $services = $response->json();
// return collect([]); return collect($services);
// } } catch (\Throwable $e) {
// $services = $response->json(); $services = File::get(base_path('templates/service-templates.json'));
// $services = collect($services)->sortKeys(); return collect(json_decode($services))->sortKeys();
// } catch (\Throwable $e) { }
// $services = collect([]); } else {
// } $services = File::get(base_path('templates/service-templates.json'));
// } return collect(json_decode($services))->sortKeys();
$services = File::get(base_path('templates/service-templates.json')); }
return collect(json_decode($services))->sortKeys();
} }
function getResourceByUuid(string $uuid, ?int $teamId = null) function getResourceByUuid(string $uuid, ?int $teamId = null)