mattermost-mobile/share_extension/android/index.js
Miguel Alatzar 459801d10b
[MM-17560] Await dismissAllModals and popToRoot prior to calling showSearchModal (#3298)
* Patch react-native-navigation

* Make navigation actions regular functions

* Fix unhandled promise rejection warning

* Missing semicolons

* Mock navigation actions

* Add unit tests for navigation actions

* Place all patches in patches directory

* Fix channel_info snapshot test
2019-09-25 15:23:45 -07:00

69 lines
1.8 KiB
JavaScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React, {PureComponent} from 'react';
import {Provider} from 'react-redux';
import {IntlProvider} from 'react-intl';
import {getTranslations} from 'app/i18n';
import {getCurrentLocale} from 'app/selectors/i18n';
import store from 'app/store';
import {extensionSelectTeamId} from './actions';
import Extension from './extension';
export default class ShareApp extends PureComponent {
constructor() {
super();
const st = store.getState();
if (st?.views?.root?.hydrationComplete) {
this.state = {init: true};
this.listenForHydration();
} else {
this.unsubscribeFromStore = store.subscribe(this.listenForHydration);
this.state = {init: false};
}
}
componentDidMount() {
this.mounted = true;
}
listenForHydration = () => {
const {dispatch, getState} = store;
const state = getState();
if (state.views.root.hydrationComplete) {
const {currentTeamId} = state.entities.teams;
if (this.unsubscribeFromStore) {
this.unsubscribeFromStore();
}
dispatch(extensionSelectTeamId(currentTeamId));
if (this.mounted) {
this.setState({init: true});
}
}
};
render() {
if (!this.state.init) {
return null;
}
const locale = getCurrentLocale(store.getState());
return (
<Provider store={store}>
<IntlProvider
locale={locale}
messages={getTranslations(locale)}
>
<Extension/>
</IntlProvider>
</Provider>
);
}
}