516da671c6
Build and Deploy to Production / build-and-deploy (push) Successful in 1m37s
- Add AppVersionService to check version and clear cache if needed - Update Configuration.Protobuf package to 0.0.4 with AppVersion proto - Integrate version check in App.razor on app initialization
63 lines
2.2 KiB
C#
63 lines
2.2 KiB
C#
using Blazored.LocalStorage;
|
|
using FrontOffice.Main.Shared;
|
|
using FrontOffice.Main.Utilities;
|
|
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.AspNetCore.WebUtilities;
|
|
using MudBlazor;
|
|
|
|
namespace FrontOffice.Main;
|
|
|
|
public partial class App
|
|
{
|
|
[Inject] private ILocalStorageService LocalStorage { get; set; } = default!;
|
|
[Inject] private AuthService AuthService { get; set; } = default!;
|
|
[Inject] private AppVersionService AppVersionService { get; set; } = default!;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await base.OnInitializedAsync();
|
|
|
|
// Check app version and clear cache if needed
|
|
await AppVersionService.CheckVersionAndClearCacheIfNeededAsync();
|
|
|
|
// Check for referral code in URL query parameters
|
|
var uri = Navigation.ToAbsoluteUri(Navigation.Uri);
|
|
var query = QueryHelpers.ParseQuery(uri.Query);
|
|
|
|
if (query.TryGetValue("ref", out var refValues))
|
|
{
|
|
var referralCode = refValues.FirstOrDefault();
|
|
if (!string.IsNullOrWhiteSpace(referralCode))
|
|
{
|
|
// Store referral code in local storage
|
|
await LocalStorage.SetItemAsync("referral:code", referralCode);
|
|
|
|
if(!await AuthService.IsAuthenticatedAsync())
|
|
{
|
|
var options = new DialogOptions
|
|
{
|
|
BackdropClick = false,
|
|
CloseOnEscapeKey = false
|
|
};
|
|
|
|
var parameters = new DialogParameters<AuthDialog>
|
|
{
|
|
{ x => x.HideCancelButton, true }
|
|
};
|
|
var dialog = await DialogService.ShowAsync<AuthDialog>("ورود به حساب کاربری", parameters, options);
|
|
var result = await dialog.Result;
|
|
|
|
if (!result.Canceled)
|
|
{
|
|
Snackbar.Add(GlobalConstants.SuccessMsg, Severity.Success);
|
|
await Task.Delay(1000);
|
|
Navigation.NavigateTo(Navigation.Uri, forceLoad: true);
|
|
StateHasChanged();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|