fix: clear timers and animation frame request before component unmounts (#8700)
Co-authored-by: Sojan Jose <sojan@pepalo.com>
This commit is contained in:
@@ -84,6 +84,10 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
beforeDestroy() {
|
||||||
|
clearTimeout(this.typingTimer);
|
||||||
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
onChange(e) {
|
onChange(e) {
|
||||||
this.$emit('input', e.target.value);
|
this.$emit('input', e.target.value);
|
||||||
|
|||||||
@@ -24,6 +24,11 @@ export default {
|
|||||||
default: () => {},
|
default: () => {},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
timeOutID: null,
|
||||||
|
};
|
||||||
|
},
|
||||||
computed: {
|
computed: {
|
||||||
replyToAttachment() {
|
replyToAttachment() {
|
||||||
if (!this.replyTo?.attachments?.length) {
|
if (!this.replyTo?.attachments?.length) {
|
||||||
@@ -34,6 +39,10 @@ export default {
|
|||||||
return this.$t(`ATTACHMENTS.${fileType}.CONTENT`);
|
return this.$t(`ATTACHMENTS.${fileType}.CONTENT`);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
beforeDestroy() {
|
||||||
|
clearTimeout(this.timeOutID);
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
navigateTo(id) {
|
navigateTo(id) {
|
||||||
const elementId = `cwmsg-${id}`;
|
const elementId = `cwmsg-${id}`;
|
||||||
@@ -41,7 +50,7 @@ export default {
|
|||||||
const el = document.getElementById(elementId);
|
const el = document.getElementById(elementId);
|
||||||
el.scrollIntoView();
|
el.scrollIntoView();
|
||||||
el.classList.add('bg-slate-100', 'dark:bg-slate-900');
|
el.classList.add('bg-slate-100', 'dark:bg-slate-900');
|
||||||
setTimeout(() => {
|
this.timeOutID = setTimeout(() => {
|
||||||
el.classList.remove('bg-slate-100', 'dark:bg-slate-900');
|
el.classList.remove('bg-slate-100', 'dark:bg-slate-900');
|
||||||
}, 500);
|
}, 500);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ export default {
|
|||||||
scrollPosition: 0,
|
scrollPosition: 0,
|
||||||
ticking: true,
|
ticking: true,
|
||||||
disableBranding: window.chatwootWebChannel.disableBranding || false,
|
disableBranding: window.chatwootWebChannel.disableBranding || false,
|
||||||
|
requestID: null,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -120,6 +121,7 @@ export default {
|
|||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
this.$el.removeEventListener('scroll', this.updateScrollPosition);
|
this.$el.removeEventListener('scroll', this.updateScrollPosition);
|
||||||
|
cancelAnimationFrame(this.requestID);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
closeWindow() {
|
closeWindow() {
|
||||||
@@ -128,7 +130,7 @@ export default {
|
|||||||
updateScrollPosition(event) {
|
updateScrollPosition(event) {
|
||||||
this.scrollPosition = event.target.scrollTop;
|
this.scrollPosition = event.target.scrollTop;
|
||||||
if (!this.ticking) {
|
if (!this.ticking) {
|
||||||
window.requestAnimationFrame(() => {
|
this.requestID = window.requestAnimationFrame(() => {
|
||||||
this.ticking = false;
|
this.ticking = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user