diff --git a/frontend/build/webpack.config.js b/frontend/build/webpack.config.js index f331cbc0b..7c1dcba83 100644 --- a/frontend/build/webpack.config.js +++ b/frontend/build/webpack.config.js @@ -82,10 +82,6 @@ module.exports = (env) => { hints: false }, - experiments: { - topLevelAwait: true - }, - plugins: [ new webpack.DefinePlugin({ __DEV__: !isProduction, diff --git a/frontend/src/App/App.js b/frontend/src/App/App.js index e7b226a5d..1eea6e082 100644 --- a/frontend/src/App/App.js +++ b/frontend/src/App/App.js @@ -7,13 +7,13 @@ import PageConnector from 'Components/Page/PageConnector'; import ApplyTheme from './ApplyTheme'; import AppRoutes from './AppRoutes'; -function App({ store, history, hasTranslationsError }) { +function App({ store, history }) { return ( - + @@ -25,8 +25,7 @@ function App({ store, history, hasTranslationsError }) { App.propTypes = { store: PropTypes.object.isRequired, - history: PropTypes.object.isRequired, - hasTranslationsError: PropTypes.bool.isRequired + history: PropTypes.object.isRequired }; export default App; diff --git a/frontend/src/Components/Page/ErrorPage.js b/frontend/src/Components/Page/ErrorPage.js index 7c8f4a8c3..77bed6a31 100644 --- a/frontend/src/Components/Page/ErrorPage.js +++ b/frontend/src/Components/Page/ErrorPage.js @@ -7,7 +7,6 @@ function ErrorPage(props) { const { version, isLocalStorageSupported, - hasTranslationsError, indexersError, indexerStatusError, indexerCategoriesError, @@ -22,8 +21,6 @@ function ErrorPage(props) { if (!isLocalStorageSupported) { errorMessage = 'Local Storage is not supported or disabled. A plugin or private browsing may have disabled it.'; - } else if (hasTranslationsError) { - errorMessage = 'Failed to load translations from API'; } else if (indexersError) { errorMessage = getErrorMessage(indexersError, 'Failed to load indexers from API'); } else if (indexerStatusError) { @@ -58,7 +55,6 @@ function ErrorPage(props) { ErrorPage.propTypes = { version: PropTypes.string.isRequired, isLocalStorageSupported: PropTypes.bool.isRequired, - hasTranslationsError: PropTypes.bool.isRequired, indexersError: PropTypes.object, indexerStatusError: PropTypes.object, indexerCategoriesError: PropTypes.object, diff --git a/frontend/src/Components/Page/PageConnector.js b/frontend/src/Components/Page/PageConnector.js index d584933e8..5ac032c0f 100644 --- a/frontend/src/Components/Page/PageConnector.js +++ b/frontend/src/Components/Page/PageConnector.js @@ -232,7 +232,6 @@ class PageConnector extends Component { render() { const { - hasTranslationsError, isPopulated, hasError, dispatchFetchTags, @@ -246,12 +245,11 @@ class PageConnector extends Component { ...otherProps } = this.props; - if (hasTranslationsError || hasError || !this.state.isLocalStorageSupported) { + if (hasError || !this.state.isLocalStorageSupported) { return ( ); } @@ -272,7 +270,6 @@ class PageConnector extends Component { } PageConnector.propTypes = { - hasTranslationsError: PropTypes.bool.isRequired, isPopulated: PropTypes.bool.isRequired, hasError: PropTypes.bool.isRequired, isSidebarVisible: PropTypes.bool.isRequired, diff --git a/frontend/src/Utilities/String/translate.js b/frontend/src/Utilities/String/translate.js index fb0ec0cb5..7483b27aa 100644 --- a/frontend/src/Utilities/String/translate.js +++ b/frontend/src/Utilities/String/translate.js @@ -1,28 +1,23 @@ import createAjaxRequest from 'Utilities/createAjaxRequest'; function getTranslations() { - return createAjaxRequest({ - global: false, + let localization = null; + const ajaxOptions = { + async: false, dataType: 'json', - url: '/localization' - }).request; -} - -let translations = {}; + url: '/localization', + success: function(data) { + localization = data.Strings; + } + }; -export function fetchTranslations() { - return new Promise(async(resolve) => { - try { - const data = await getTranslations(); - translations = data.Strings; + createAjaxRequest(ajaxOptions); - resolve(true); - } catch (error) { - resolve(false); - } - }); + return localization; } +const translations = getTranslations(); + export default function translate(key, args = []) { const translation = translations[key] || key; diff --git a/frontend/src/index.js b/frontend/src/index.js index 8ed0414c6..59911154e 100644 --- a/frontend/src/index.js +++ b/frontend/src/index.js @@ -2,7 +2,7 @@ import { createBrowserHistory } from 'history'; import React from 'react'; import { render } from 'react-dom'; import createAppStore from 'Store/createAppStore'; -import { fetchTranslations } from 'Utilities/String/translate'; +import App from './App/App'; import './preload'; import './polyfills'; @@ -11,14 +11,11 @@ import './index.css'; const history = createBrowserHistory(); const store = createAppStore(history); -const hasTranslationsError = !await fetchTranslations(); -const { default: App } = await import('./App/App'); render( , document.getElementById('root') );