/// <summary> /// Called when the <see cref="Document"/> identifier is set. /// </summary> /// <returns>An asynchronous task.</returns> protected override async Task OnParametersSetAsync() { var newUid = WebUtility.UrlDecode(Uid); if (newUid != uid) { var history = string.Empty; var query = NavigationHelper.GetQueryString( NavigationService.Uri); if (query.ContainsKey(nameof(history))) { history = query[nameof(history)]; } Loading = false; NotFound = false; uid = newUid; try { Loading = true; if (string.IsNullOrWhiteSpace(history)) { await LoadingService.WrapExecutionAsync( async() => Document = await DocumentService.LoadDocumentAsync(uid)); NotFound = Document == null; Audit = false; } else { await LoadingService.WrapExecutionAsync( async() => Document = await DocumentService.LoadDocumentSnapshotAsync(Guid.Parse(history), uid)); Audit = true; NotFound = Document == null; } Loading = false; await TitleService.SetTitleAsync($"Viewing {Title}"); } catch { NotFound = true; } } await base.OnParametersSetAsync(); }