fix: Use addEventListener instead of onmessage to listen to chatwoot-dashboard-app:fetch-info (#10342)

This commit is contained in:
Shivam Mishra
2024-10-29 09:13:47 +05:30
committed by GitHub
parent c6c36b1b36
commit 035a037313

View File

@@ -1,5 +1,6 @@
<script>
import LoadingState from 'dashboard/components/widgets/LoadingState.vue';
export default {
components: {
LoadingState,
@@ -51,19 +52,19 @@ export default {
}
},
},
mounted() {
window.onmessage = e => {
if (
typeof e.data !== 'string' ||
e.data !== 'chatwoot-dashboard-app:fetch-info'
) {
return;
}
this.onIframeLoad(0);
};
window.addEventListener('message', this.triggerEvent);
},
unmounted() {
window.removeEventListener('message', this.triggerEvent);
},
methods: {
triggerEvent(event) {
if (!this.isVisible) return;
if (event.data === 'chatwoot-dashboard-app:fetch-info') {
this.onIframeLoad(0);
}
},
getFrameId(index) {
return `dashboard-app--frame-${this.position}-${index}`;
},