TASVideos / tasvideos

The code for the live TASVideos website
https://tasvideos.org/
GNU General Public License v3.0
62 stars 29 forks source link

Select the newly created game on catalog page #1752

Closed vadosnaprimer closed 3 weeks ago

vadosnaprimer commented 6 months ago

When you catalog some submission for a game you need to create, you go to the catalog page and hit the "New" button for the game, but after you've created it on https://tasvideos.org/Games/Edit?returnUrl=/Submissions/Catalog/8862 and hit "Save", you get redirected back to Submissions/Catalog/8862 and the game is not selected.

If you then create a version for that game from the same page, both the game and the version will be selected when you return, so it would be ideal if the game got selected right away. But I couldn't figure out the syntax to manipulate redirect return URL parameters one by one.

For example I was able to select the game by replacing

https://github.com/TASVideos/tasvideos/blob/828407adb97d7cfd00bc591ad740e755bd7ddf91/TASVideos/Pages/Games/Edit.cshtml.cs#L167

with

return string.IsNullOrWhiteSpace(HttpContext.Request.ReturnUrl())
            ? BasePageRedirect("Index", new { game.Id })
            : BaseReturnUrlRedirect($"?GameId={game.Id}");

But then I need to fix the way it returns from the version creation page which also appends its own ? breaking the final syntax:

https://github.com/TASVideos/tasvideos/blob/828407adb97d7cfd00bc591ad740e755bd7ddf91/TASVideos/Pages/Games/Versions/Edit.cshtml.cs#L177

Note: parameter manipulation in the return URL needs to not break when we don't have to create a new game and we just pick an existing one, but we create a new version for it.