diff --git a/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/Authorized/Settings/ProfileSection.razor b/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/Authorized/Settings/ProfileSection.razor index 6aafb63c6b..eaa7c5e34b 100644 --- a/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/Authorized/Settings/ProfileSection.razor +++ b/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/Authorized/Settings/ProfileSection.razor @@ -1,9 +1,5 @@ @inherits AppComponentBase -@{ - var imageUrl = User?.ProfileImageName is null ? null : $"{profileImageUrl}&file={User.ProfileImageName}"; -} -
@if (Loading) @@ -32,7 +28,7 @@ @if (isUploading is false) { diff --git a/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/Authorized/Settings/ProfileSection.razor.cs b/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/Authorized/Settings/ProfileSection.razor.cs index db9418bff3..8ff389a4f6 100644 --- a/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/Authorized/Settings/ProfileSection.razor.cs +++ b/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Pages/Authorized/Settings/ProfileSection.razor.cs @@ -20,7 +20,6 @@ public partial class ProfileSection private BitFileUpload fileUploadRef = default!; private readonly EditUserDto editUserDto = new(); - protected override async Task OnInitAsync() { var accessToken = await PrerenderStateService.GetValue(AuthTokenProvider.GetAccessToken); @@ -34,11 +33,13 @@ protected override async Task OnInitAsync() protected override void OnParametersSet() { - User!.Patch(editUserDto); - - profileImageUrl = new Uri(AbsoluteServerAddress, $"/api/Attachment/GetProfileImage/{User!.Id}?version={User.ConcurrencyStamp}").ToString(); - base.OnParametersSet(); + + if (User is not null) + { + User.Patch(editUserDto); + profileImageUrl = new Uri(AbsoluteServerAddress, $"/api/Attachment/GetProfileImage/{User.Id}?file={User.ProfileImageName}&version={User.ConcurrencyStamp}").ToString(); + } } @@ -99,7 +100,9 @@ private async Task HandleOnUploadComplete() { var updatedUser = await userController.GetCurrentUser(CurrentCancellationToken); - User.ProfileImageName = updatedUser.ProfileImageName; + updatedUser.Patch(User); + + profileImageUrl = new Uri(AbsoluteServerAddress, $"/api/Attachment/GetProfileImage/{User.Id}?file={User.ProfileImageName}&version={User.ConcurrencyStamp}").ToString(); PublishUserDataUpdated(); } diff --git a/src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Controllers/AttachmentController.cs b/src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Controllers/AttachmentController.cs index 83cf8ba68c..7a409cf620 100644 --- a/src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Controllers/AttachmentController.cs +++ b/src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Controllers/AttachmentController.cs @@ -91,7 +91,7 @@ public async Task RemoveProfileImage(CancellationToken cancellationToken) [AllowAnonymous] [HttpGet("{userId}")] - [ResponseCache(Duration = 7 * 24 * 3600, Location = ResponseCacheLocation.Any)] + [ResponseCache(Duration = 7 * 24 * 3600, Location = ResponseCacheLocation.Any, VaryByQueryKeys = new string[] { "*" })] public async Task GetProfileImage(Guid userId, CancellationToken cancellationToken) { var user = await userManager.FindByIdAsync(userId.ToString()); diff --git a/src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Controllers/Statistics/StatisticsController.cs b/src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Controllers/Statistics/StatisticsController.cs index 9cbba4b900..2801488586 100644 --- a/src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Controllers/Statistics/StatisticsController.cs +++ b/src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Controllers/Statistics/StatisticsController.cs @@ -11,7 +11,7 @@ public partial class StatisticsController : AppControllerBase, IStatisticsContro [AllowAnonymous] [HttpGet("{packageId}")] - [ResponseCache(Duration = 1 * 24 * 3600, Location = ResponseCacheLocation.Any)] + [ResponseCache(Duration = 1 * 24 * 3600, Location = ResponseCacheLocation.Any, VaryByQueryKeys = new string[] { "*" })] public async Task GetNugetStats(string packageId, CancellationToken cancellationToken) { return await nugetHttpClient.GetPackageStats(packageId, cancellationToken);