diff --git a/CHANGELOG.md b/CHANGELOG.md
index be5863d..df54319 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,16 @@
# Changelog
+## 0.8.9 - 2024-07-13
+
+### 🔇 Remove logs
+
+- Remove the loggings
+
+### 🐛 Fix bugs
+
+- Better manage to the lifecycle cancellation token source
+- Prevent a null reference on CmJsInterop: don't nullify it on component disposal
+
## 0.8.8 - 2024-06-16
### ⬆️ Upgrade dependencies
diff --git a/CodeMirror6/CodeMirror6.csproj b/CodeMirror6/CodeMirror6.csproj
index 37365a3..e3022fe 100644
--- a/CodeMirror6/CodeMirror6.csproj
+++ b/CodeMirror6/CodeMirror6.csproj
@@ -9,7 +9,7 @@
GaelJ.BlazorCodeMirror6
true
GaelJ.BlazorCodeMirror6
- 0.8.8
+ 0.8.9
true
snupkg
true
diff --git a/CodeMirror6/CodeMirror6WrapperInternal.razor.cs b/CodeMirror6/CodeMirror6WrapperInternal.razor.cs
index 62b85b4..daab3c6 100644
--- a/CodeMirror6/CodeMirror6WrapperInternal.razor.cs
+++ b/CodeMirror6/CodeMirror6WrapperInternal.razor.cs
@@ -270,7 +270,7 @@ public partial class CodeMirror6WrapperInternal : ComponentBase, IAsyncDisposabl
internal CodeMirrorConfiguration Config = null!;
private bool shouldRender = true;
private bool IsCodeMirrorInitialized;
- private readonly CancellationTokenSource LifeCycleCancellationTokenSource = new();
+ private CancellationTokenSource LifeCycleCancellationTokenSource = new();
///
/// Life-cycle method invoked when the component is initialized.
@@ -335,20 +335,38 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
private async Task InitializeJsInterop()
{
- if (CmJsInterop is null) {
- Logger.LogDebug("Initializing CodeMirror JS Interop with id {id}", Setup.Id);
- if (LifeCycleCancellationTokenSource.IsCancellationRequested) return;
- CmJsInterop = new CodeMirrorJsInterop(JSRuntime, this);
- if (LifeCycleCancellationTokenSource.IsCancellationRequested) return;
- if (!await CmJsInterop.PropertySetters.InitCodeMirror()) return;
- if (GetMentionCompletions is not null) {
- var mentionCompletions = await GetMentionCompletions();
- if (!await CmJsInterop.PropertySetters.SetMentionCompletions(mentionCompletions)) return;
+ if (CmJsInterop is null || !IsCodeMirrorInitialized) {
+ try {
+ try {
+ LifeCycleCancellationTokenSource.Cancel();
+ }
+ catch (ObjectDisposedException) {
+ return;
+ }
+ LifeCycleCancellationTokenSource = new();
+
+ var token = LifeCycleCancellationTokenSource.Token;
+ Logger.LogInformation("Initializing CodeMirror JS Interop with id {id}...", Setup.Id);
+ if (token.IsCancellationRequested) return;
+ CmJsInterop = new CodeMirrorJsInterop(JSRuntime, this);
+
+ if (token.IsCancellationRequested) return;
+ if (!await CmJsInterop.PropertySetters.InitCodeMirror()) return;
+
+ if (GetMentionCompletions is not null) {
+ var mentionCompletions = await GetMentionCompletions();
+ if (token.IsCancellationRequested) return;
+ if (!await CmJsInterop.PropertySetters.SetMentionCompletions(mentionCompletions)) return;
+ }
+ if (token.IsCancellationRequested) return;
+ IsCodeMirrorInitialized = true;
+ await InvokeAsync(StateHasChanged);
+ await OnParametersSetAsync();
+ }
+ catch (OperationCanceledException) {
+ }
+ catch (ObjectDisposedException) {
}
- if (LifeCycleCancellationTokenSource.IsCancellationRequested) return;
- IsCodeMirrorInitialized = true;
- await InvokeAsync(StateHasChanged);
- await OnParametersSetAsync();
}
}
@@ -519,7 +537,6 @@ public async ValueTask DisposeAsync()
catch (ObjectDisposedException) {}
if (CmJsInterop?.IsJSReady == true)
await CmJsInterop.DisposeAsync();
- CmJsInterop = null;
try {
LinterCancellationTokenSource.Cancel();
LinterCancellationTokenSource.Dispose();
diff --git a/Examples.BlazorServer/Examples.BlazorServer.csproj b/Examples.BlazorServer/Examples.BlazorServer.csproj
index b5bcaad..e93e049 100644
--- a/Examples.BlazorServer/Examples.BlazorServer.csproj
+++ b/Examples.BlazorServer/Examples.BlazorServer.csproj
@@ -4,7 +4,7 @@
enable
false
enable
- 0.8.8
+ 0.8.9
diff --git a/Examples.BlazorServerInteractive/Examples.BlazorServerInteractive.csproj b/Examples.BlazorServerInteractive/Examples.BlazorServerInteractive.csproj
index f946917..6b5f407 100644
--- a/Examples.BlazorServerInteractive/Examples.BlazorServerInteractive.csproj
+++ b/Examples.BlazorServerInteractive/Examples.BlazorServerInteractive.csproj
@@ -4,7 +4,7 @@
enable
enable
false
- 0.8.8
+ 0.8.9
diff --git a/Examples.BlazorWasm/Examples.BlazorWasm.csproj b/Examples.BlazorWasm/Examples.BlazorWasm.csproj
index 37fade0..4f5502b 100644
--- a/Examples.BlazorWasm/Examples.BlazorWasm.csproj
+++ b/Examples.BlazorWasm/Examples.BlazorWasm.csproj
@@ -4,7 +4,7 @@
enable
enable
false
- 0.8.8
+ 0.8.9
diff --git a/Examples.Common/Examples.Common.csproj b/Examples.Common/Examples.Common.csproj
index c526cf6..32fba76 100644
--- a/Examples.Common/Examples.Common.csproj
+++ b/Examples.Common/Examples.Common.csproj
@@ -5,7 +5,7 @@
enable
enable
false
- 0.8.8
+ 0.8.9
diff --git a/NEW_CHANGELOG.md b/NEW_CHANGELOG.md
index c988096..6cf9d19 100644
--- a/NEW_CHANGELOG.md
+++ b/NEW_CHANGELOG.md
@@ -1,3 +1,8 @@
-### ⬆️ Upgrade dependencies
+### 🔇 Remove logs
-- Update nuget packages
+- Remove the loggings
+
+### 🐛 Fix bugs
+
+- Better manage to the lifecycle cancellation token source
+- Prevent a null reference on CmJsInterop: don't nullify it on component disposal