Skip to content

Commit

Permalink
Added page progress
Browse files Browse the repository at this point in the history
  • Loading branch information
Aragas committed May 15, 2023
1 parent f77a6ff commit c1ae5f4
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 10 deletions.
3 changes: 3 additions & 0 deletions src/BUTR.Site.NexusMods.Client/App.razor
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
</NotFound>
</Router>
<NotificationProvider Location="@NotificationLocation.Start" />
<PageProgressProvider />
<ModalProvider />
<MessageProvider />
</CascadingAuthenticationState>
</Blazorise.ThemeProvider>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,8 @@
<ProjectReference Include="..\BUTR.Site.NexusMods.Shared\BUTR.Site.NexusMods.Shared.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="Components\Modals\" />
</ItemGroup>

</Project>
7 changes: 6 additions & 1 deletion src/BUTR.Site.NexusMods.Client/Pages/Basic/Profile.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
@page "/profile"

@inject NavigationManager _navigationManager
@inject IPageProgressService _pageProgressService
@inject IUserClient _userClient
@inject IDiscordClient _discordClient
@inject ISteamClient _steamClient
Expand Down Expand Up @@ -157,19 +158,23 @@ else

protected override async Task OnInitializedAsync()
{
await _pageProgressService.Go(null, options => options.Color = Color.Info);
//await _pageProgressService.Go(25, options => options.Color = Color.Info);
_user = (await _userClient.ProfileAsync()).Data;

var discordTask = _user?.DiscordUserId is not null ? _discordClient.GetUserInfoAsync() : Task.FromResult<DiscordUserInfoAPIResponse>(new(null!, string.Empty));
var steamTask = _user?.SteamUserId is not null ? _steamClient.GetUserInfoAsync() : Task.FromResult<SteamUserInfoAPIResponse>(new(null!, string.Empty));
var gogTask = _user?.GogUserId is not null ? _gogClient.GetUserInfoAsync() : Task.FromResult<GOGUserInfoAPIResponse>(new(null!, string.Empty));
await Task.WhenAll(discordTask, steamTask, gogTask);

//await _pageProgressService.Go(75, options => options.Color = Color.Info);
_discordUser = await discordTask is { Data: { } dataDiscord } ? new DiscordUserInfo2(dataDiscord) : null;
_steamUser = await steamTask is { Data: { } dataSteam } ? new SteamUserInfo2(dataSteam) : null;
_gogUser = await gogTask is { Data: { } dataGog } ? new GOGUserInfo2(dataGog) : null;

if (_gutterRow is not null)
_gutterRow.Gutter = (5,5);
await _pageProgressService.Go(-1);
}

protected override Task OnParametersSetAsync()
Expand Down
12 changes: 9 additions & 3 deletions src/BUTR.Site.NexusMods.Client/Pages/Discord/OAuthCallback.razor
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
@attribute [Authorize]
@page "/discord-oauth-callback"

@inject IDiscordClient _discordClient;
@inject AuthenticationProvider _authenticationProvider;
@inject ILocalStorageService _localStorage;
@inject NavigationManager _navigationManager;
@inject IPageProgressService _pageProgressService
@inject ILocalStorageService _localStorage;
@inject AuthenticationProvider _authenticationProvider;
@inject IDiscordClient _discordClient;

<Container>
<Row Flex="@Flex.JustifyContent.Center">
Expand Down Expand Up @@ -79,6 +80,7 @@
{
await base.OnInitializedAsync();

await _pageProgressService.Go(0, options => options.Color = Color.Info);
if (!await _localStorage.ContainKeyAsync("discord_state"))
{
_status = "FAILURE";
Expand All @@ -102,9 +104,12 @@
return;
}

await _pageProgressService.Go(25, options => options.Color = Color.Info);
await _discordClient.LinkAsync(queryCode);
await _pageProgressService.Go(50, options => options.Color = Color.Info);
_ = await _authenticationProvider.ValidateAsync();

await _pageProgressService.Go(75, options => options.Color = Color.Info);
var userInfo = await _discordClient.GetUserInfoAsync();
_userInfo = new DiscordUserInfo2(userInfo.Data);
_status = "SUCCESS";
Expand All @@ -119,6 +124,7 @@
finally
{
await _localStorage.RemoveItemAsync("discord_state");
await _pageProgressService.Go(null);
}
}

Expand Down
15 changes: 12 additions & 3 deletions src/BUTR.Site.NexusMods.Client/Pages/GOG/OAuthCallback.razor
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
@attribute [Authorize]
@page "/gog-oauth-callback"

@inject IGOGClient _gogClient;
@inject AuthenticationProvider _authenticationProvider;
@inject ILocalStorageService _localStorage;
@inject NavigationManager _navigationManager;
@inject IPageProgressService _pageProgressService
@inject AuthenticationProvider _authenticationProvider;
@inject IGOGClient _gogClient;

<Container>
<Row Flex="@Flex.JustifyContent.Center">
Expand Down Expand Up @@ -59,14 +59,19 @@
{
await base.OnInitializedAsync();

await _pageProgressService.Go(0, options => options.Color = Color.Info);

var queries = _navigationManager.QueryString();
var queryCode = queries["code"];

try
{
await _pageProgressService.Go(25, options => options.Color = Color.Info);
await _gogClient.LinkAsync(queryCode);
await _pageProgressService.Go(50, options => options.Color = Color.Info);
_ = await _authenticationProvider.ValidateAsync();

await _pageProgressService.Go(75, options => options.Color = Color.Info);
var userInfo = await _gogClient.GetUserInfoAsync();
_userInfo = new GOGUserInfo2(userInfo.Data);
_status = "SUCCESS";
Expand All @@ -78,6 +83,10 @@
_message = "Failed to link!";
_image = Failure;
}
finally
{
await _pageProgressService.Go(null);
}
}

}
16 changes: 13 additions & 3 deletions src/BUTR.Site.NexusMods.Client/Pages/Steam/OpenIdCallback.razor
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
@attribute [Authorize]
@page "/steam-openid-callback"

@inject ISteamClient _steamClient;
@inject AuthenticationProvider _authenticationProvider;
@inject NavigationManager _navigationManager;
@inject IPageProgressService _pageProgressService
@inject AuthenticationProvider _authenticationProvider;
@inject ISteamClient _steamClient;

<Container>
<Row Flex="@Flex.JustifyContent.Center">
Expand Down Expand Up @@ -80,13 +81,18 @@
{
await base.OnInitializedAsync();

await _pageProgressService.Go(0, options => options.Color = Color.Info);

var queries = _navigationManager.QueryString();

try
{
await _steamClient.LinkAsync(queries.AllKeys.Select(x => new { Key = x, Value = queries[x] }).ToDictionary(x => x.Key, x => x.Value));
await _pageProgressService.Go(25, options => options.Color = Color.Info);
await _steamClient.LinkAsync(queries.AllKeys.Select(x => new {Key = x, Value = queries[x]}).ToDictionary(x => x.Key, x => x.Value));
await _pageProgressService.Go(50, options => options.Color = Color.Info);
_ = await _authenticationProvider.ValidateAsync();

await _pageProgressService.Go(75, options => options.Color = Color.Info);
var userInfo = await _steamClient.GetUserInfoAsync();
_userInfo = new SteamUserInfo2(userInfo.Data);
_status = "SUCCESS";
Expand All @@ -98,6 +104,10 @@
_message = "Failed to link!";
_image = Failure;
}
finally
{
await _pageProgressService.Go(null);
}
}

}

0 comments on commit c1ae5f4

Please sign in to comment.