Hi,
I think there might be an issue with the CookieConsentService.CookiePreferencesChanged event:
|
public event EventHandler<CookiePreferences> CookiePreferencesChanged; |
I use the CookieConsentHandler component in InteractiveServer render mode (without prerender).
I'm handling the CookieConsentService.CookiePreferencesChanged event, but the event fires two times. I thought, it was the issue with CookiePreferences equality check:
#39
That is a bug, but it didn't resolve the issue.
After further investigation, I found it has something to do with the CookieConsentEventHandler broadcasting the CookiePreferencesChanged event:
|
public async Task BroadcastCookiePreferencesChangedAsync(CookiePreferences cookiePreferences) |
|
{ |
|
_ = Task.Run(() => CookiePreferencesChanged?.Invoke(this, cookiePreferences)); |
|
|
|
await PublishToJsAsync(JsBroadcastEventCookiePreferencesChanged, |
|
JsonSerializer.Serialize(cookiePreferences)); |
|
} |
Unlike the other events this one doesn't check _runtimeContext.RendersUserInterface.
It calls the event on the server and then publishes that event to JS towards WASM. Which in turn pops again from javascript as a second call.
As I've said, the component is in the InteractiveServer render mode.
I uderstand the intention for the component to be render mode agnostic, but in this case this doesn't seem to function correctly.
When I comment one of those callings, the event fires only once as expected.
Could You please check this scenario in InteractiveServer render mode ?
Thanks.
Hi,
I think there might be an issue with the CookieConsentService.CookiePreferencesChanged event:
BytexDigital.Blazor.Components.CookieConsent/BytexDigital.Blazor.Components.CookieConsent/CookieConsentService.cs
Line 55 in 83da45a
I use the CookieConsentHandler component in InteractiveServer render mode (without prerender).
I'm handling the CookieConsentService.CookiePreferencesChanged event, but the event fires two times. I thought, it was the issue with CookiePreferences equality check:
#39
That is a bug, but it didn't resolve the issue.
After further investigation, I found it has something to do with the CookieConsentEventHandler broadcasting the CookiePreferencesChanged event:
BytexDigital.Blazor.Components.CookieConsent/BytexDigital.Blazor.Components.CookieConsent/Broadcasting/CookieConsentEventHandler.cs
Lines 54 to 60 in 83da45a
Unlike the other events this one doesn't check _runtimeContext.RendersUserInterface.
It calls the event on the server and then publishes that event to JS towards WASM. Which in turn pops again from javascript as a second call.
As I've said, the component is in the InteractiveServer render mode.
I uderstand the intention for the component to be render mode agnostic, but in this case this doesn't seem to function correctly.
When I comment one of those callings, the event fires only once as expected.
Could You please check this scenario in InteractiveServer render mode ?
Thanks.