mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-17 17:14:18 +02:00
Revert "Fixed: Ensure translations are fetched before loading app"
This reverts commit 0fc52ae16f
.
This commit is contained in:
@@ -82,10 +82,6 @@ module.exports = (env) => {
|
|||||||
hints: false
|
hints: false
|
||||||
},
|
},
|
||||||
|
|
||||||
experiments: {
|
|
||||||
topLevelAwait: true
|
|
||||||
},
|
|
||||||
|
|
||||||
plugins: [
|
plugins: [
|
||||||
new webpack.DefinePlugin({
|
new webpack.DefinePlugin({
|
||||||
__DEV__: !isProduction,
|
__DEV__: !isProduction,
|
||||||
|
@@ -7,13 +7,13 @@ import PageConnector from 'Components/Page/PageConnector';
|
|||||||
import ApplyTheme from './ApplyTheme';
|
import ApplyTheme from './ApplyTheme';
|
||||||
import AppRoutes from './AppRoutes';
|
import AppRoutes from './AppRoutes';
|
||||||
|
|
||||||
function App({ store, history, hasTranslationsError }) {
|
function App({ store, history }) {
|
||||||
return (
|
return (
|
||||||
<DocumentTitle title={window.Prowlarr.instanceName}>
|
<DocumentTitle title={window.Prowlarr.instanceName}>
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
<ConnectedRouter history={history}>
|
<ConnectedRouter history={history}>
|
||||||
<ApplyTheme>
|
<ApplyTheme>
|
||||||
<PageConnector hasTranslationsError={hasTranslationsError}>
|
<PageConnector>
|
||||||
<AppRoutes app={App} />
|
<AppRoutes app={App} />
|
||||||
</PageConnector>
|
</PageConnector>
|
||||||
</ApplyTheme>
|
</ApplyTheme>
|
||||||
@@ -25,8 +25,7 @@ function App({ store, history, hasTranslationsError }) {
|
|||||||
|
|
||||||
App.propTypes = {
|
App.propTypes = {
|
||||||
store: PropTypes.object.isRequired,
|
store: PropTypes.object.isRequired,
|
||||||
history: PropTypes.object.isRequired,
|
history: PropTypes.object.isRequired
|
||||||
hasTranslationsError: PropTypes.bool.isRequired
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default App;
|
export default App;
|
||||||
|
@@ -7,7 +7,6 @@ function ErrorPage(props) {
|
|||||||
const {
|
const {
|
||||||
version,
|
version,
|
||||||
isLocalStorageSupported,
|
isLocalStorageSupported,
|
||||||
hasTranslationsError,
|
|
||||||
indexersError,
|
indexersError,
|
||||||
indexerStatusError,
|
indexerStatusError,
|
||||||
indexerCategoriesError,
|
indexerCategoriesError,
|
||||||
@@ -22,8 +21,6 @@ function ErrorPage(props) {
|
|||||||
|
|
||||||
if (!isLocalStorageSupported) {
|
if (!isLocalStorageSupported) {
|
||||||
errorMessage = 'Local Storage is not supported or disabled. A plugin or private browsing may have disabled it.';
|
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) {
|
} else if (indexersError) {
|
||||||
errorMessage = getErrorMessage(indexersError, 'Failed to load indexers from API');
|
errorMessage = getErrorMessage(indexersError, 'Failed to load indexers from API');
|
||||||
} else if (indexerStatusError) {
|
} else if (indexerStatusError) {
|
||||||
@@ -58,7 +55,6 @@ function ErrorPage(props) {
|
|||||||
ErrorPage.propTypes = {
|
ErrorPage.propTypes = {
|
||||||
version: PropTypes.string.isRequired,
|
version: PropTypes.string.isRequired,
|
||||||
isLocalStorageSupported: PropTypes.bool.isRequired,
|
isLocalStorageSupported: PropTypes.bool.isRequired,
|
||||||
hasTranslationsError: PropTypes.bool.isRequired,
|
|
||||||
indexersError: PropTypes.object,
|
indexersError: PropTypes.object,
|
||||||
indexerStatusError: PropTypes.object,
|
indexerStatusError: PropTypes.object,
|
||||||
indexerCategoriesError: PropTypes.object,
|
indexerCategoriesError: PropTypes.object,
|
||||||
|
@@ -232,7 +232,6 @@ class PageConnector extends Component {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
hasTranslationsError,
|
|
||||||
isPopulated,
|
isPopulated,
|
||||||
hasError,
|
hasError,
|
||||||
dispatchFetchTags,
|
dispatchFetchTags,
|
||||||
@@ -246,12 +245,11 @@ class PageConnector extends Component {
|
|||||||
...otherProps
|
...otherProps
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
if (hasTranslationsError || hasError || !this.state.isLocalStorageSupported) {
|
if (hasError || !this.state.isLocalStorageSupported) {
|
||||||
return (
|
return (
|
||||||
<ErrorPage
|
<ErrorPage
|
||||||
{...this.state}
|
{...this.state}
|
||||||
{...otherProps}
|
{...otherProps}
|
||||||
hasTranslationsError={hasTranslationsError}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -272,7 +270,6 @@ class PageConnector extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PageConnector.propTypes = {
|
PageConnector.propTypes = {
|
||||||
hasTranslationsError: PropTypes.bool.isRequired,
|
|
||||||
isPopulated: PropTypes.bool.isRequired,
|
isPopulated: PropTypes.bool.isRequired,
|
||||||
hasError: PropTypes.bool.isRequired,
|
hasError: PropTypes.bool.isRequired,
|
||||||
isSidebarVisible: PropTypes.bool.isRequired,
|
isSidebarVisible: PropTypes.bool.isRequired,
|
||||||
|
@@ -1,28 +1,23 @@
|
|||||||
import createAjaxRequest from 'Utilities/createAjaxRequest';
|
import createAjaxRequest from 'Utilities/createAjaxRequest';
|
||||||
|
|
||||||
function getTranslations() {
|
function getTranslations() {
|
||||||
return createAjaxRequest({
|
let localization = null;
|
||||||
global: false,
|
const ajaxOptions = {
|
||||||
|
async: false,
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
url: '/localization'
|
url: '/localization',
|
||||||
}).request;
|
success: function(data) {
|
||||||
}
|
localization = data.Strings;
|
||||||
|
|
||||||
let translations = {};
|
|
||||||
|
|
||||||
export function fetchTranslations() {
|
|
||||||
return new Promise(async(resolve) => {
|
|
||||||
try {
|
|
||||||
const data = await getTranslations();
|
|
||||||
translations = data.Strings;
|
|
||||||
|
|
||||||
resolve(true);
|
|
||||||
} catch (error) {
|
|
||||||
resolve(false);
|
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
|
createAjaxRequest(ajaxOptions);
|
||||||
|
|
||||||
|
return localization;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const translations = getTranslations();
|
||||||
|
|
||||||
export default function translate(key, args = []) {
|
export default function translate(key, args = []) {
|
||||||
const translation = translations[key] || key;
|
const translation = translations[key] || key;
|
||||||
|
|
||||||
|
@@ -2,7 +2,7 @@ import { createBrowserHistory } from 'history';
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { render } from 'react-dom';
|
import { render } from 'react-dom';
|
||||||
import createAppStore from 'Store/createAppStore';
|
import createAppStore from 'Store/createAppStore';
|
||||||
import { fetchTranslations } from 'Utilities/String/translate';
|
import App from './App/App';
|
||||||
|
|
||||||
import './preload';
|
import './preload';
|
||||||
import './polyfills';
|
import './polyfills';
|
||||||
@@ -11,14 +11,11 @@ import './index.css';
|
|||||||
|
|
||||||
const history = createBrowserHistory();
|
const history = createBrowserHistory();
|
||||||
const store = createAppStore(history);
|
const store = createAppStore(history);
|
||||||
const hasTranslationsError = !await fetchTranslations();
|
|
||||||
const { default: App } = await import('./App/App');
|
|
||||||
|
|
||||||
render(
|
render(
|
||||||
<App
|
<App
|
||||||
store={store}
|
store={store}
|
||||||
history={history}
|
history={history}
|
||||||
hasTranslationsError={hasTranslationsError}
|
|
||||||
/>,
|
/>,
|
||||||
document.getElementById('root')
|
document.getElementById('root')
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user