[REWORK] Changes saving client and channel info
This commit is contained in:
@@ -29,24 +29,39 @@ public partial class Channels : ComponentBase
|
||||
return;
|
||||
}
|
||||
|
||||
var clientPrep = (ClientChannel)result.Data;
|
||||
if (clientPrep?.YouTubeClient == null)
|
||||
var clientChannel = (ClientChannel)result.Data;
|
||||
if (clientChannel?.YouTubeClient == null)
|
||||
{
|
||||
Snackbar.Add("No YouTube client received.", Severity.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
var savedResult = await ClientService.SaveClientAsync(clientPrep.YouTubeClient, clientPrep.Channel);
|
||||
if (!savedResult.IsSuccess)
|
||||
{
|
||||
Snackbar.Add($"Failed to store client: {savedResult.Error?.Description ?? "Unknown!"}", Severity.Error);
|
||||
}
|
||||
else
|
||||
|
||||
var savedClientResult = await ClientService.SaveClientAsync(clientChannel.YouTubeClient);
|
||||
if (savedClientResult.IsSuccess)
|
||||
{
|
||||
if (_table != null)
|
||||
{
|
||||
await _table.ReloadServerData();
|
||||
}
|
||||
Snackbar.Add($"Client {clientPrep.Channel?.Handle ?? clientPrep.YouTubeClient.Id} saved!", Severity.Success);
|
||||
Snackbar.Add($"Client {clientChannel.Channel?.Handle ?? clientChannel.YouTubeClient.Id} saved!", Severity.Success);
|
||||
ClientService.AddClient(clientChannel.YouTubeClient);
|
||||
}
|
||||
else
|
||||
{
|
||||
Snackbar.Add($"Failed to store client: {savedClientResult.Error?.Description ?? "Unknown!"}", Severity.Error);
|
||||
}
|
||||
|
||||
if (clientChannel.Channel == null)
|
||||
{
|
||||
Snackbar.Add("No channel information received!", Severity.Warning);
|
||||
}
|
||||
else
|
||||
{
|
||||
var saveChannelResult = await LibraryService.SaveChannelAsync(clientChannel.Channel);
|
||||
if (!saveChannelResult.IsSuccess)
|
||||
{
|
||||
Snackbar.Add("Failed to save channel information", Severity.Warning);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user