mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-24 01:08:08 +01:00
79b34a0fa2
* Restore onboarding modal Revert 5ba8b3a396895ecec083c5258aaf9084d584a7c4 * Change greeting elephant graphic, fix up some design issues * Fix wrong link color in onboarding modal
70 lines
2.1 KiB
JavaScript
70 lines
2.1 KiB
JavaScript
import React from 'react';
|
|
import { Provider } from 'react-redux';
|
|
import PropTypes from 'prop-types';
|
|
import configureStore from '../store/configureStore';
|
|
import { showOnboardingOnce } from '../actions/onboarding';
|
|
import { BrowserRouter, Route } from 'react-router-dom';
|
|
import { ScrollContext } from 'react-router-scroll-4';
|
|
import UI from '../features/ui';
|
|
import { hydrateStore } from '../actions/store';
|
|
import { connectUserStream } from '../actions/streaming';
|
|
import { IntlProvider, addLocaleData } from 'react-intl';
|
|
import { getLocale } from '../locales';
|
|
import initialState from '../initial_state';
|
|
|
|
const { localeData, messages } = getLocale();
|
|
addLocaleData(localeData);
|
|
|
|
export const store = configureStore();
|
|
const hydrateAction = hydrateStore(initialState);
|
|
store.dispatch(hydrateAction);
|
|
|
|
export default class Mastodon extends React.PureComponent {
|
|
|
|
static propTypes = {
|
|
locale: PropTypes.string.isRequired,
|
|
};
|
|
|
|
componentDidMount() {
|
|
this.disconnect = store.dispatch(connectUserStream());
|
|
|
|
// Desktop notifications
|
|
// Ask after 1 minute
|
|
if (typeof window.Notification !== 'undefined' && Notification.permission === 'default') {
|
|
window.setTimeout(() => Notification.requestPermission(), 60 * 1000);
|
|
}
|
|
|
|
// Protocol handler
|
|
// Ask after 5 minutes
|
|
if (typeof navigator.registerProtocolHandler !== 'undefined') {
|
|
const handlerUrl = window.location.protocol + '//' + window.location.host + '/intent?uri=%s';
|
|
window.setTimeout(() => navigator.registerProtocolHandler('web+mastodon', handlerUrl, 'Mastodon'), 5 * 60 * 1000);
|
|
}
|
|
|
|
store.dispatch(showOnboardingOnce());
|
|
}
|
|
|
|
componentWillUnmount () {
|
|
if (this.disconnect) {
|
|
this.disconnect();
|
|
this.disconnect = null;
|
|
}
|
|
}
|
|
|
|
render () {
|
|
const { locale } = this.props;
|
|
|
|
return (
|
|
<IntlProvider locale={locale} messages={messages}>
|
|
<Provider store={store}>
|
|
<BrowserRouter basename='/web'>
|
|
<ScrollContext>
|
|
<Route path='/' component={UI} />
|
|
</ScrollContext>
|
|
</BrowserRouter>
|
|
</Provider>
|
|
</IntlProvider>
|
|
);
|
|
}
|
|
|
|
}
|