1
0
mirror of synced 2024-11-28 08:30:56 +01:00
This commit is contained in:
S-Sebb 2023-12-16 23:49:05 +00:00
commit 0fbdfae3a8

View File

@ -1,6 +1,7 @@
using SharedProject.Models;
using SharedProject.Utils;
using System.Text.Json;
using Throw;
namespace TaikoLocalServer.Controllers.Api;
@ -123,6 +124,21 @@ public class UserSettingsController : BaseController<UserSettingsController>
user.ColorLimb = userSetting.LimbColor;
user.CostumeData = JsonSerializer.Serialize(costumes);
// If a locked tone is selected, unlock it
uint[] toneFlg = { 0u };
try
{
toneFlg = JsonSerializer.Deserialize<uint[]>(user.ToneFlgArray)!;
}
catch (JsonException e)
{
Logger.LogError(e, "Parsing tone flg json data failed");
}
toneFlg.ThrowIfNull("Tone flg should never be null!");
toneFlg = toneFlg.Append(0u).Append(userSetting.ToneId).Distinct().ToArray();
user.ToneFlgArray = JsonSerializer.Serialize(toneFlg);
await userDatumService.UpdateUserDatum(user);
return NoContent();