chore: enable close button in react-native widget (#1910)

This commit is contained in:
Muhsin Keloth 2021-03-15 10:10:26 -07:00 committed by GitHub
parent b6f4006c15
commit 7d5493ac78
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 12 deletions

View file

@ -13,7 +13,7 @@
<script>
import { mapGetters, mapActions } from 'vuex';
import { setHeader } from 'widget/helpers/axios';
import { IFrameHelper } from 'widget/helpers/utils';
import { IFrameHelper, RNHelper } from 'widget/helpers/utils';
import Router from './views/Router';
import { getLocale } from './helpers/urlParamsHelper';
@ -45,6 +45,9 @@ export default {
isIFrame() {
return IFrameHelper.isIFrame();
},
isRNWebView() {
return RNHelper.isRNWebView();
},
},
mounted() {
const { websiteToken, locale } = window.chatwootWebChannel;
@ -59,15 +62,9 @@ export default {
this.fetchAvailableAgents(websiteToken);
this.setLocale(getLocale(window.location.search));
}
// Pass cookie to react native widget
if (window.ReactNativeWebView) {
if (this.isRNWebView) {
this.registerListeners();
window.ReactNativeWebView.postMessage(
JSON.stringify({
type: 'auth-token',
value: window.authToken,
})
);
this.sendRNWebViewLoadedEvent();
}
this.$store.dispatch('conversationAttributes/get');
this.setWidgetColor(window.chatwootWebChannel);
@ -196,6 +193,15 @@ export default {
},
});
},
sendRNWebViewLoadedEvent() {
RNHelper.sendMessage({
event: 'loaded',
config: {
authToken: window.authToken,
channelConfig: window.chatwootWebChannel,
},
});
},
},
};
</script>