Repository URL to install this package:
|
Version:
0.0.15 ▾
|
import * as tslib_1 from "tslib";
import * as React from 'react';
import { observer } from 'xmobx/mobx-react';
import { EMPTY_ARRAY } from 'exotic';
/**
* @todo this was being used for @@studio fallback, right now it needs code splitting to stay separate
*/
import { oneRouter } from '@skava/router';
import { NotFound } from '@skava/packages/features/Empty';
import { Studio, studioContainer, StyledMain, PreloaderContainer, } from '@skava/packages/pages/Studio';
import { Preloader } from '@skava/ui';
/**
* @todo - could render subroutes in here
* @todo - shouldn't connect to studio here?
* @todo - this is rendering studio WAY TOO MANY TIMES
*/
let Fallback = class Fallback extends React.Component {
// @note if we did not fetch a page, nothing happens
// if we do, unmount in <Studio> will reset
async componentWillMount() {
const hasPage = await studioContainer.hasPage();
if (hasPage) {
studioContainer.fetchPageIfNeeded();
}
}
render() {
const isPreview = oneRouter.get('preview') === true;
const isStudio = isPreview || studioContainer.hasCurrentPage;
const { className, ...remainingProps } = this.props;
// @note - this will observably update
if (isStudio) {
return React.createElement(Studio, null);
}
else {
// @todo url of page?
// return <NotFound title="404" />
/**
* @note
* before studioHasPage call complete 404 will be shown due to async call
* if the studio page is available -> 404 page will be shown then it will reload the page to show studio page
* to fix the above bug, below condition is must required. as `studioContainer.currentPageId` initially `@@EMPTY`
* after hasPage call complete it will become `null`
*/
if (studioContainer.currentPageId === null) {
return React.createElement(NotFound, { className: className, title: "404", hasIcon: false });
}
else {
return (React.createElement(StyledMain, { className: className, key: "main" },
React.createElement(PreloaderContainer, null,
React.createElement(Preloader, { breedType: "preloader" }))));
}
}
}
};
Fallback.defaultProps = {
className: 'loading',
list: EMPTY_ARRAY,
};
Fallback = tslib_1.__decorate([
observer
], Fallback);
export { Fallback };
export default Fallback;
//# sourceMappingURL=FallbackPage.js.map