Skip to content

Commit dc2b09d

Browse files
author
infinitnet
committed
improve subscription handling and cleanups
1 parent a34432c commit dc2b09d

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

rdo.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,10 @@ const ImportantTermsComponent = compose([
221221

222222
useEffect(() => {
223223
return () => {
224+
if (editorSubscription) {
225+
editorSubscription();
226+
editorSubscription = null;
227+
}
224228
debouncedDisplayRelevantDetails.cancel();
225229
}
226230
}, []);
@@ -316,4 +320,21 @@ const handleEditorChange = () => {
316320

317321
const debouncedHandleEditorChange = debounce(handleEditorChange, 3000);
318322

319-
subscribe(debouncedHandleEditorChange);
323+
let editorSubscription = null;
324+
325+
const subscribeEditorChange = () => {
326+
if (editorSubscription) {
327+
editorSubscription();
328+
editorSubscription = null;
329+
}
330+
331+
editorSubscription = subscribe(debouncedHandleEditorChange);
332+
};
333+
334+
const clearGlobalVariables = () => {
335+
globalHighlightingState = false;
336+
lastComputedContent = '';
337+
lastComputedTerms = '';
338+
};
339+
340+
subscribeEditorChange();

relevant-density-optimizer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
* Author URI: https://infinitnet.io/
77
* Plugin URI: https://infinitnet.io/relevant-density-optimizer/
88
* Update URI: https://github.com/infinitnet/relevant-density-optimizer
9-
* Version: 1.6.3
9+
* Version: 1.6.4
1010
* License: GPLv3
1111
* Text Domain: relevant-density-optimizer
1212
*/
1313

1414
namespace Infinitnet\RDO;
1515

16-
define('RDO_VERSION', '1.6.3');
16+
define('RDO_VERSION', '1.6.4');
1717

1818
function rdo_enqueue_block_editor_assets() {
1919
if (!wp_script_is('rdo-plugin-js', 'enqueued')) {

0 commit comments

Comments
 (0)