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