@using LANCommander.Launcher.Data.Models @using LANCommander.Launcher.Models @inject UserService UserService @inject ProfileService ProfileService @inject AuthenticationService AuthenticationService @inject NavigationManager NavigationManager @inject ModalService ModalService Change Name Settings @if (!ConnectionState.OfflineModeEnabled) { Logout } @code { [CascadingParameter] public ConnectionState ConnectionState { get; set; } Models.Settings Settings = null; User User; Guid AvatarId = Guid.Empty; string Alias = Settings.DEFAULT_GAME_USERNAME; protected override async Task OnInitializedAsync() { ProfileService.OnProfileDownloaded += async (sender, args) => { User = await UserService.GetCurrentUser(); AvatarId = User?.Avatar?.Id ?? Guid.Empty; Alias = String.IsNullOrWhiteSpace(User?.Alias) ? User?.UserName ?? Settings.DEFAULT_GAME_USERNAME : User.Alias; }; await ProfileService.DownloadProfileInfoAsync(); } async Task ChangeAlias() { var modalOptions = new ModalOptions() { Title = "Change Name", Maximizable = false, DefaultMaximized = false, Closable = true, Centered = true }; var modalRef = ModalService.CreateModal(modalOptions, User.Alias); modalRef.OnOk = async (newName) => { await ProfileService.ChangeAlias(newName); await ProfileService.DownloadProfileInfoAsync(); Settings = SettingService.GetSettings(); await InvokeAsync(StateHasChanged); }; } async Task Logout() { await AuthenticationService.Logout(); NavigationManager.NavigateTo("/Authenticate"); } }