Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion app/Actions/GetOoklaSpeedtestServers.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,15 @@ class GetOoklaSpeedtestServers
*/
public function handle(): array
{
return collect(self::fetch())->mapWithKeys(function (array $item) {
$servers = self::fetch();

// If the first item is not an array, treat as error or empty
if (empty($servers) || ! is_array($servers) || (isset($servers[0]) && ! is_array($servers[0]))) {
// Return error message as a single option so user can see the error
return ['error' => $servers[0] ?? 'Unable to retrieve servers'];
}

return collect($servers)->mapWithKeys(function (array $item) {
return [
$item['id'] => ($item['sponsor'] ?? 'Unknown').' ('.($item['name'] ?? 'Unknown').', '.$item['id'].')',
];
Expand Down