[CHANGE] No need to reload client from db if already loaded && can be loaded without checking library service
This commit is contained in:
@@ -58,18 +58,18 @@ public class ClientService(IServiceScopeFactory scopeFactory, ILogger<ClientServ
|
|||||||
return new ListResultReturn<YouTubeClientItem>(comparedClients, accountsResult.Total);
|
return new ListResultReturn<YouTubeClientItem>(comparedClients, accountsResult.Total);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Result<YouTubeClient>> LoadClientByIdAsync(string id, bool forceLoad = false, CancellationToken cancellationToken = default)
|
public async Task<Result<YouTubeClient>> LoadClientByIdAsync(string id, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
|
if (_loadedClients.TryGetValue(id, out var client))
|
||||||
|
{
|
||||||
|
return client;
|
||||||
|
}
|
||||||
|
|
||||||
if (_libraryService == null)
|
if (_libraryService == null)
|
||||||
{
|
{
|
||||||
return ResultError.Fail("Library service is not initialized!.");
|
return ResultError.Fail("Library service is not initialized!.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!forceLoad && _loadedClients.TryGetValue(id, out var client))
|
|
||||||
{
|
|
||||||
return client;
|
|
||||||
}
|
|
||||||
|
|
||||||
var clientResult = await _libraryService.GetChannelByIdAsync(id, cancellationToken);
|
var clientResult = await _libraryService.GetChannelByIdAsync(id, cancellationToken);
|
||||||
if (!clientResult.IsSuccess)
|
if (!clientResult.IsSuccess)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user