Skip to content

Commit

Permalink
Refactor: Make GetClientAccessTokenAsync private and awaitable
Browse files Browse the repository at this point in the history
Changed the GetClientAccessTokenAsync method from public to private as it does not need to be openly available. This method is now properly awaited in all calls to ensure sequential execution and prevent potential issues related to concurrency or incomplete tasks.
  • Loading branch information
DineshSolanki committed Jul 24, 2024
1 parent 264fdbd commit cd48d9d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions FoliCon/Modules/DeviantArt/DArt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static async Task<DArt> GetInstanceAsync(string clientSecret, string clie
return dArt;
}

public async Task GetClientAccessTokenAsync()
private async Task GetClientAccessTokenAsync()
{
if (!_cache.TryGetValue("DArtToken", out string cachedToken))
{
Expand Down Expand Up @@ -93,7 +93,7 @@ private async Task<string> GenerateNewAccessToken()

public async Task<DArtBrowseResult> Browse(string query, int offset = 0)
{
GetClientAccessTokenAsync();
await GetClientAccessTokenAsync();

var url = GetBrowseApiUrl(query, offset);
using var response = await Services.HttpC.GetAsync(new Uri(url));
Expand All @@ -111,7 +111,7 @@ public async Task<DArtBrowseResult> Browse(string query, int offset = 0)
/// <returns>The DArtDownloadResponse object containing the download details.</returns>
public async Task<DArtDownloadResponse> Download(string deviationId)
{
GetClientAccessTokenAsync();
await GetClientAccessTokenAsync();
var dArtDownloadResponse = await GetDArtDownloadResponseAsync(deviationId);
await TryExtraction(deviationId, dArtDownloadResponse, CancellationToken.None, new Progress<ProgressInfo>(_ => { }));

Expand Down Expand Up @@ -144,7 +144,7 @@ public async Task<DArtDownloadResponse> ExtractDeviation(string deviationId,
DArtDownloadResponse dArtDownloadResponse, CancellationToken cancellationToken,
IProgress<ProgressInfo> progressCallback)
{
GetClientAccessTokenAsync();
await GetClientAccessTokenAsync();
return await TryExtraction(deviationId, dArtDownloadResponse, cancellationToken, progressCallback);

}
Expand Down

0 comments on commit cd48d9d

Please sign in to comment.