chat: fix sigil overlay perf issue
Changes the sigil overlay to only start checking for its position when it
becomes visible.
Fixes:
@@ -19,31 +19,26 @@ export class OverlaySigil extends Component {
this.profileShow = this.profileShow.bind(this);
this.profileHide = this.profileHide.bind(this);
+ this.updateContainerInterval = null;
+ }
+
+ profileShow() {
+ this.updateContainerOffset();
+ this.setState({ profileClicked: true });
this.updateContainerInterval = setInterval(
this.updateContainerOffset.bind(this),
1000
);
}
- componentDidMount() {
- this.updateContainerOffset();
- }
-
- componentWillUnmount() {
+ profileHide() {
+ this.setState({ profileClicked: false });
if(this.updateContainerInterval) {
clearInterval(this.updateContainerInterval);
this.updateContainerInterval = null;
}
}
- profileShow() {
- this.setState({ profileClicked: true });
- }
-
- profileHide() {
- this.setState({ profileClicked: false });
- }
-
updateContainerOffset() {
if (this.containerRef && this.containerRef.current) {
const parent = this.containerRef.current.offsetParent;
