mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-02 03:57:52 +00:00
fix: Use addEventListener instead of onmessage to listen to chatwoot-dashboard-app:fetch-info (#10342)
This commit is contained in:
@@ -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}`;
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user