[CHANGE] No need to reload client from db if already loaded && can be loaded without checking library service
This commit is contained in:
parent
34e029ec79
commit
1555ae9f3d
1 changed files with 6 additions and 6 deletions
|
|
@ -58,17 +58,17 @@ public class ClientService(IServiceScopeFactory scopeFactory, ILogger<ClientServ
|
|||
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)
|
||||
{
|
||||
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);
|
||||
if (!clientResult.IsSuccess)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue