Fix IGDB result selection: use DOM data attributes + pass igdb_id to backend
Build & Deploy / build-and-deploy (push) Successful in 58s
Build & Deploy / build-and-deploy (push) Successful in 58s
Two issues fixed:
1. Frontend closure bug: IGDB result buttons used Svelte {#each} closure
with onclick={() => doUpload(result.name)}. When clicking the 3rd
result, the 1st result's handler sometimes fired. Fixed by reading
data-name from e.currentTarget.dataset instead of JS closure.
2. Backend scrape mismatch: when user selected 'Blood' from IGDB
results, backend's autoScrape searched for 'Blood' and could match
'Captain Blood' first (alphabetical), overwriting metadata.
Now passes igdb_id along with title so backend uses the EXACT
IGDB entry the user selected via applyIgdbId() instead of
auto-searching.
This commit is contained in:
@@ -34,7 +34,8 @@ public class UploadResource {
|
||||
@Consumes(MediaType.MULTIPART_FORM_DATA)
|
||||
public Response upload(
|
||||
@RestForm("file") FileUpload upload,
|
||||
@RestForm("title") String title
|
||||
@RestForm("title") String title,
|
||||
@RestForm("igdb_id") Integer igdbId
|
||||
) throws Exception {
|
||||
if (upload == null) {
|
||||
return Response.status(400).entity(Map.of("error", "No file provided")).build();
|
||||
@@ -103,9 +104,13 @@ public class UploadResource {
|
||||
game.setReady(true);
|
||||
svc.save(game);
|
||||
|
||||
// Auto-populate from IGDB (non-blocking if credentials are set)
|
||||
// Auto-populate from IGDB (use provided igdb_id or auto-search)
|
||||
if (igdb.isConfigured()) {
|
||||
igdb.autoScrape(game);
|
||||
if (igdbId != null) {
|
||||
igdb.applyIgdbId(game, igdbId);
|
||||
} else {
|
||||
igdb.autoScrape(game);
|
||||
}
|
||||
if (game.isHasCover() || game.getYear() != null || game.getGenre() != null
|
||||
|| (game.getVideos() != null && !game.getVideos().isEmpty())
|
||||
|| (game.getScreenshots() != null && !game.getScreenshots().isEmpty())) {
|
||||
|
||||
Reference in New Issue
Block a user