* Add api methods for subscription * Small changes * little changes in remark.tsx * disallow pass className to Button and Input * Subscribe block * add RSS and Email subscription drobdowns * add hook useTheme * unify dropdown import/export * Change API * rename subscribe methods * add unsubscribe method * Add email subscription to settings and user * Refactor and add new steps * render by single component * add final step * add unsubscribe step it user is subscribed * Add tests * Update subscription logic * test without mocking redux methods but with mocking store * update user in store after subscribe and unsubscribe * little changes in subscription flow * fix drobdown size * Fix RSS subscription link for site * fix link * add test for RSS subscription * Fix showing email subscription * it don't show to unauth users * it don't show to anonymous users * it tested * isUserAnonymous is a bit rewrited * isUserAnonymous is tested * Make Email button visible for anon users * React X supporst Fragments thats why .babelrc changed * disabled button is more visible * fix hovering on disabled buttons * create mocks for tests * move email dropdown to __subscribe-by-email
81 lines
2.1 KiB
TypeScript
81 lines
2.1 KiB
TypeScript
/** @jsx createElement */
|
|
import loadPolyfills from '@app/common/polyfills';
|
|
import { createElement, render } from 'preact';
|
|
import 'preact/debug';
|
|
|
|
import { Provider } from 'react-redux';
|
|
import { ConnectedRoot } from '@app/components/root';
|
|
import { UserInfo } from '@app/components/user-info';
|
|
import reduxStore from '@app/store';
|
|
|
|
// importing css
|
|
import '@app/components/list-comments';
|
|
|
|
import { NODE_ID, BASE_URL } from '@app/common/constants';
|
|
import { StaticStore } from '@app/common/static_store';
|
|
import api from '@app/common/api';
|
|
import { bindActionCreators } from 'redux';
|
|
import { fetchHiddenUsers } from './store/user/actions';
|
|
import { restoreProvider } from './store/provider/actions';
|
|
import { restoreCollapsedThreads } from './store/thread/actions';
|
|
|
|
if (document.readyState === 'loading') {
|
|
document.addEventListener('DOMContentLoaded', init);
|
|
} else {
|
|
init();
|
|
}
|
|
|
|
async function init(): Promise<void> {
|
|
__webpack_public_path__ = BASE_URL + '/web/';
|
|
|
|
await loadPolyfills();
|
|
|
|
const node = document.getElementById(NODE_ID);
|
|
|
|
if (!node) {
|
|
console.error("Remark42: Can't find root node."); // eslint-disable-line no-console
|
|
return;
|
|
}
|
|
|
|
const boundActions = bindActionCreators(
|
|
{ fetchHiddenUsers, restoreProvider, restoreCollapsedThreads },
|
|
reduxStore.dispatch
|
|
);
|
|
boundActions.fetchHiddenUsers();
|
|
boundActions.restoreProvider();
|
|
boundActions.restoreCollapsedThreads();
|
|
|
|
const params = window.location.search
|
|
.replace(/^\?/, '')
|
|
.split('&')
|
|
.reduce<{ [key: string]: string }>((memo, value) => {
|
|
const vals = value.split('=');
|
|
if (vals.length === 2) {
|
|
memo[vals[0]] = vals[1];
|
|
}
|
|
return memo;
|
|
}, {});
|
|
|
|
StaticStore.config = await api.getConfig();
|
|
|
|
if (params.page === 'user-info') {
|
|
return render(
|
|
<div id={NODE_ID}>
|
|
<div className="root root_user-info">
|
|
<Provider store={reduxStore}>
|
|
<UserInfo />
|
|
</Provider>
|
|
</div>
|
|
</div>,
|
|
node
|
|
);
|
|
}
|
|
|
|
render(
|
|
<Provider store={reduxStore}>
|
|
<ConnectedRoot />
|
|
</Provider>,
|
|
node
|
|
);
|
|
}
|