Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions resources/locales/active.de.toml
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,14 @@ other = "A - Spiel auswählen\nB - Zum vorherigen Bildschirm zurück\nX - Spiele
hash = "sha1-77fdd51f105473d648b8c22b6897d0f12d0dd360"
other = "Spieleliste Hilfe"

[games_list_load_error]
hash = "sha1-a1b2c3d4e5f6"
other = "Spiele konnten nicht geladen werden.\nBitte versuchen Sie es später erneut."

[games_list_load_timeout]
hash = "sha1-a1b2c3d4e5f7"
other = "Verbindung abgelaufen!\nBitte überprüfen Sie Ihre Netzwerkverbindung."

[games_list_loading]
hash = "sha1-e7222980840d29aac1ef616e64615c6f2128cd83"
other = "{{.Name}} wird geladen..."
Expand Down
2 changes: 2 additions & 0 deletions resources/locales/active.en.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ game_options_title = "Game Options"
games_list_filtered_out = "No games in {{.Name}} match your platform mappings"
games_list_help_body = "A - Select a game\nB - Go back to the previous screen\nX - Search for games by name\nSelect - Toggle multi-select mode\n In multi-select mode:\n - Use D-Pad to navigate\n - Press A to toggle selection\n - Press Start to confirm selections\nMenu - Show this help screen\nD-Pad - Navigate the game list"
games_list_help_title = "Games List Help"
games_list_load_error = "Failed to load games.\nPlease try again later."
games_list_load_timeout = "Connection timed out!\nPlease check your network connection."
games_list_loading = "Loading {{.Name}}..."
games_list_no_games = "No games found for {{.Name}}"
games_list_no_results = "No results found for \"{{.Query}}\""
Expand Down
8 changes: 8 additions & 0 deletions resources/locales/active.es.toml
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,14 @@ other = "A - Seleccionar un juego\nB - Volver a la pantalla anterior\nX - Buscar
hash = "sha1-77fdd51f105473d648b8c22b6897d0f12d0dd360"
other = "Ayuda de Lista de Juegos"

[games_list_load_error]
hash = "sha1-a1b2c3d4e5f6"
other = "Error al cargar los juegos.\nPor favor, inténtelo más tarde."

[games_list_load_timeout]
hash = "sha1-a1b2c3d4e5f7"
other = "¡Conexión agotada!\nPor favor, verifique su conexión de red."

[games_list_loading]
hash = "sha1-e7222980840d29aac1ef616e64615c6f2128cd83"
other = "Cargando {{.Name}}..."
Expand Down
8 changes: 8 additions & 0 deletions resources/locales/active.fr.toml
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,14 @@ other = "A - Sélectionner un jeu\nB - Retourner à l'écran précédent\nX - Re
hash = "sha1-77fdd51f105473d648b8c22b6897d0f12d0dd360"
other = "Aide - Liste des Jeux"

[games_list_load_error]
hash = "sha1-a1b2c3d4e5f6"
other = "Échec du chargement des jeux.\nVeuillez réessayer plus tard."

[games_list_load_timeout]
hash = "sha1-a1b2c3d4e5f7"
other = "Connexion expirée !\nVeuillez vérifier votre connexion réseau."

[games_list_loading]
hash = "sha1-e7222980840d29aac1ef616e64615c6f2128cd83"
other = "Chargement de {{.Name}}..."
Expand Down
8 changes: 8 additions & 0 deletions resources/locales/active.it.toml
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,14 @@ other = "A - Seleziona un gioco\nB - Torna alla schermata precedente\nX - Cerca
hash = "sha1-77fdd51f105473d648b8c22b6897d0f12d0dd360"
other = "Aiuto Lista Giochi"

[games_list_load_error]
hash = "sha1-a1b2c3d4e5f6"
other = "Impossibile caricare i giochi.\nRiprova più tardi."

[games_list_load_timeout]
hash = "sha1-a1b2c3d4e5f7"
other = "Connessione scaduta!\nVerifica la tua connessione di rete."

[games_list_loading]
hash = "sha1-e7222980840d29aac1ef616e64615c6f2128cd83"
other = "Caricamento {{.Name}}..."
Expand Down
8 changes: 8 additions & 0 deletions resources/locales/active.ja.toml
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,14 @@ other = "A - ゲームを選択\nB - 前の画面に戻る\nX - 名前でゲー
hash = "sha1-77fdd51f105473d648b8c22b6897d0f12d0dd360"
other = "ゲームリストのヘルプ"

[games_list_load_error]
hash = "sha1-a1b2c3d4e5f6"
other = "ゲームの読み込みに失敗しました。\n後でもう一度お試しください。"

[games_list_load_timeout]
hash = "sha1-a1b2c3d4e5f7"
other = "接続がタイムアウトしました!\nネットワーク接続を確認してください。"

[games_list_loading]
hash = "sha1-e7222980840d29aac1ef616e64615c6f2128cd83"
other = "{{.Name}}を読み込み中..."
Expand Down
8 changes: 8 additions & 0 deletions resources/locales/active.pt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,14 @@ other = "A - Selecionar um jogo\nB - Voltar à tela anterior\nX - Buscar jogos p
hash = "sha1-77fdd51f105473d648b8c22b6897d0f12d0dd360"
other = "Ajuda da Lista de Jogos"

[games_list_load_error]
hash = "sha1-a1b2c3d4e5f6"
other = "Falha ao carregar os jogos.\nPor favor, tente novamente mais tarde."

[games_list_load_timeout]
hash = "sha1-a1b2c3d4e5f7"
other = "Conexão expirou!\nPor favor, verifique sua conexão de rede."

[games_list_loading]
hash = "sha1-e7222980840d29aac1ef616e64615c6f2128cd83"
other = "Carregando {{.Name}}..."
Expand Down
8 changes: 8 additions & 0 deletions resources/locales/active.ru.toml
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,14 @@ other = "A - Выбрать игру\nB - Вернуться на предыду
hash = "sha1-77fdd51f105473d648b8c22b6897d0f12d0dd360"
other = "Справка по списку игр"

[games_list_load_error]
hash = "sha1-a1b2c3d4e5f6"
other = "Не удалось загрузить игры.\nПожалуйста, попробуйте позже."

[games_list_load_timeout]
hash = "sha1-a1b2c3d4e5f7"
other = "Время соединения истекло!\nПожалуйста, проверьте сетевое подключение."

[games_list_loading]
hash = "sha1-e7222980840d29aac1ef616e64615c6f2128cd83"
other = "Загрузка {{.Name}}..."
Expand Down
66 changes: 30 additions & 36 deletions ui/games_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ func (s *GameListScreen) Draw(input GameListInput) (ScreenResult[GameListOutput]
if len(games) == 0 {
loaded, err := s.loadGames(input)
if err != nil {
return withCode(GameListOutput{}, gaba.ExitCodeError), err
s.showErrorMessage(err)
return back(GameListOutput{}), nil
}
games = loaded.games
hasBIOS = loaded.hasBIOS
Expand Down Expand Up @@ -461,13 +462,33 @@ func (s *GameListScreen) showFilteredOutMessage(collectionName string) {
)
}

const fetchPageSize = 1000
func (s *GameListScreen) showErrorMessage(err error) {
var message string

classifiedErr := romm.ClassifyError(err)
if errors.Is(classifiedErr, romm.ErrTimeout) {
message = i18n.Localize(&goi18n.Message{ID: "games_list_load_timeout", Other: "Connection timed out!\nPlease check your network connection."}, nil)
} else {
message = i18n.Localize(&goi18n.Message{ID: "games_list_load_error", Other: "Failed to load games.\nPlease try again later."}, nil)
}

gaba.ProcessMessage(
message,
gaba.ProcessMessageOptions{ShowThemeBackground: true},
func() (interface{}, error) {
time.Sleep(time.Second * 2)
return nil, nil
},
)
}

func fetchList(config *utils.Config, host romm.Host, queryID int, fetchType fetchType) ([]romm.Rom, error) {
logger := gaba.GetLogger()

// Build query for cache key and freshness check
query := romm.GetRomsQuery{}
query := romm.GetRomsQuery{
Limit: 10000,
}
var cacheKey string

switch fetchType {
Expand All @@ -494,46 +515,19 @@ func fetchList(config *utils.Config, host romm.Host, queryID int, fetchType fetc
// Fetch from API
rc := utils.GetRommClient(host, config.ApiTimeout)

var allGames []romm.Rom
page := 1

for {
opt := romm.GetRomsQuery{
Page: page,
Limit: fetchPageSize,
}

switch fetchType {
case ftPlatform:
opt.PlatformID = queryID
case ftCollection:
opt.CollectionID = queryID
}

res, err := rc.GetRoms(opt)
if err != nil {
return nil, err
}

allGames = append(allGames, res.Items...)
logger.Debug("Fetched games page", "page", page, "count", len(res.Items), "total", res.Total, "fetched", len(allGames))

// Check if we've fetched all items
if len(allGames) >= res.Total || len(res.Items) == 0 {
break
}

page++
res, err := rc.GetRoms(query)
if err != nil {
return nil, err
}

logger.Debug("Fetched all games", "total", len(allGames))
logger.Debug("Fetched games", "count", len(res.Items), "total", res.Total)

// Save to cache
if err := utils.SaveGamesToCache(cacheKey, allGames); err != nil {
if err := utils.SaveGamesToCache(cacheKey, res.Items); err != nil {
logger.Debug("Failed to save games to cache", "error", err)
}

return allGames, nil
return res.Items, nil
}

func filterList(itemList []romm.Rom, filter string) []romm.Rom {
Expand Down