Skip to content

Commit

Permalink
Fix logic of upload cover image
Browse files Browse the repository at this point in the history
  • Loading branch information
charles7668 committed Dec 11, 2024
1 parent ca12a6d commit 0aea310
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
9 changes: 5 additions & 4 deletions GameManager/Components/Pages/components/Card.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,18 +179,19 @@ private async Task OnEdit()
return;
try
{
if ((resultModel.Cover == null && GameInfoParam.CoverPath != null)
if ((string.IsNullOrEmpty(resultModel.Cover) && !string.IsNullOrEmpty(GameInfoParam.CoverPath))
|| (CoverIsLocalFile(resultModel.Cover) && !CoverIsLocalFile(GameInfoParam.CoverPath)))
{
await ConfigService.DeleteCoverImage(GameInfoParam.CoverPath);
}
else if (resultModel.Cover != null &&
(!CoverIsLocalFile(GameInfoParam.CoverPath) || GameInfoParam.CoverPath == null) &&
else if (!string.IsNullOrEmpty(resultModel.Cover) &&
(!CoverIsLocalFile(GameInfoParam.CoverPath) ||
string.IsNullOrEmpty(GameInfoParam.CoverPath)) &&
CoverIsLocalFile(resultModel.Cover))
{
resultModel.Cover = await ConfigService.AddCoverImage(resultModel.Cover);
}
else if (resultModel.Cover != null &&
else if (!string.IsNullOrEmpty(resultModel.Cover) &&
CoverIsLocalFile(resultModel.Cover))
{
await ConfigService.ReplaceCoverImage(resultModel.Cover, GameInfoParam.CoverPath);
Expand Down
9 changes: 5 additions & 4 deletions GameManager/Components/Pages/components/GameDetail.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,18 +195,19 @@ private async Task OnEditGameInfo()
return;
try
{
if ((resultModel.Cover == null && _gameInfo.CoverPath != null)
if ((string.IsNullOrEmpty(resultModel.Cover) && !string.IsNullOrEmpty(_gameInfo.CoverPath))
|| (CoverIsLocalFile(resultModel.Cover) && !CoverIsLocalFile(_gameInfo.CoverPath)))
{
await ConfigService.DeleteCoverImage(_gameInfo.CoverPath);
}
else if (resultModel.Cover != null &&
(!CoverIsLocalFile(_gameInfo.CoverPath) || _gameInfo.CoverPath == null) &&
else if (!string.IsNullOrEmpty(resultModel.Cover) &&
(!CoverIsLocalFile(_gameInfo.CoverPath) ||
string.IsNullOrEmpty(_gameInfo.CoverPath)) &&
CoverIsLocalFile(resultModel.Cover))
{
resultModel.Cover = await ConfigService.AddCoverImage(resultModel.Cover);
}
else if (resultModel.Cover != null &&
else if (!string.IsNullOrEmpty(resultModel.Cover) &&
CoverIsLocalFile(resultModel.Cover))
{
await ConfigService.ReplaceCoverImage(resultModel.Cover, _gameInfo.CoverPath);
Expand Down

0 comments on commit 0aea310

Please sign in to comment.