Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User timezone caching #15796

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ UpdateEditorContext context
await context.Updater.TryUpdateModelAsync(model, Prefix);
userTimeZone.TimeZoneId = model.TimeZoneId;

// Remove the cache entry, don't update it, as the form might still fail validation for other reasons.
await _userTimeZoneService.UpdateUserTimeZoneAsync(user);

return await EditAsync(userTimeZone, context);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.DependencyInjection;
using OrchardCore.Users.Handlers;
using OrchardCore.Users.TimeZone.Services;

namespace OrchardCore.Users.TimeZone.Handlers;
public class TimeZoneUserEventHandler : UserEventHandlerBase
{
private readonly UserTimeZoneService _userTimeZoneService;

public TimeZoneUserEventHandler(UserTimeZoneService userTimeZoneService) => _userTimeZoneService = userTimeZoneService;

public override async Task DeletedAsync(UserDeleteContext context) => await _userTimeZoneService.UpdateUserTimeZoneAsync(context.User);

public override async Task UpdatedAsync(UserUpdateContext context) => await _userTimeZoneService.UpdateUserTimeZoneAsync(context.User);
}
3 changes: 3 additions & 0 deletions src/OrchardCore.Modules/OrchardCore.Users/TimeZone/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using Microsoft.Extensions.DependencyInjection;
using OrchardCore.DisplayManagement.Handlers;
using OrchardCore.Modules;
using OrchardCore.Users.Handlers;
using OrchardCore.Users.Models;
using OrchardCore.Users.TimeZone.Drivers;
using OrchardCore.Users.TimeZone.Handlers;
using OrchardCore.Users.TimeZone.Services;

namespace OrchardCore.Users.TimeZone
Expand All @@ -15,6 +17,7 @@ public override void ConfigureServices(IServiceCollection services)
services.AddScoped<ITimeZoneSelector, UserTimeZoneSelector>();
services.AddSingleton<UserTimeZoneService>();
services.AddScoped<IDisplayDriver<User>, UserTimeZoneDisplayDriver>();
services.AddScoped<IUserEventHandler, TimeZoneUserEventHandler>();
}
}
}