diff options
author | Ajay Ramachandran <[email protected]> | 2020-05-10 20:32:49 -0400 |
---|---|---|
committer | Ajay Ramachandran <[email protected]> | 2020-05-10 20:32:49 -0400 |
commit | 2f842a0455698d49fc1328d6d0264ba134494d07 (patch) | |
tree | cc949f9408c269441b558e3878dfe1b86e6b6c85 /src | |
parent | 7c38b1f8f28db643611c610621e35e99373e1e93 (diff) | |
download | SponsorBlock-2f842a0455698d49fc1328d6d0264ba134494d07.tar.gz SponsorBlock-2f842a0455698d49fc1328d6d0264ba134494d07.zip |
Remove config listener from EditComponent properly
Diffstat (limited to 'src')
-rw-r--r-- | src/components/SponsorTimeEditComponent.tsx | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/components/SponsorTimeEditComponent.tsx b/src/components/SponsorTimeEditComponent.tsx index 07f20cba..e67f9d65 100644 --- a/src/components/SponsorTimeEditComponent.tsx +++ b/src/components/SponsorTimeEditComponent.tsx @@ -29,6 +29,8 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo categoryOptionRef: React.RefObject<HTMLSelectElement>; + configUpdateListener: () => void; + constructor(props: SponsorTimeEditProps) { super(props); @@ -49,7 +51,16 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo }); // Add as a config listener - Config.configListeners.push(this.configUpdate.bind(this)); + if (!this.configUpdateListener) { + this.configUpdateListener = () => this.configUpdate(); + Config.configListeners.push(this.configUpdate.bind(this)); + } + } + + componentWillUnmount() { + if (this.configUpdateListener) { + Config.configListeners.splice(Config.configListeners.indexOf(this.configUpdate.bind(this))); + } } render() { |