0
0
Fork 0

Fix /share and cleanup and reorganize frontend locale loading (#25240)

This commit is contained in:
Renaud Chaput 2023-06-02 15:00:27 +02:00 committed by GitHub
parent 5fae2de454
commit b0780cfeed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 152 additions and 638 deletions

View file

@ -229,14 +229,14 @@ ready(() => {
[].forEach.call(document.querySelectorAll('[data-admin-component]'), element => {
const componentName = element.getAttribute('data-admin-component');
const { locale, ...componentProps } = JSON.parse(element.getAttribute('data-props'));
const componentProps = JSON.parse(element.getAttribute('data-props'));
import('../mastodon/containers/admin_component').then(({ default: AdminComponent }) => {
return import('../mastodon/components/admin/' + componentName).then(({ default: Component }) => {
const root = createRoot(element);
root.render (
<AdminComponent locale={locale}>
<AdminComponent>
<Component {...componentProps} />
</AdminComponent>,
);

View file

@ -1,14 +1,15 @@
import './public-path';
import main from "mastodon/main"
import { start } from '../mastodon/common';
import { loadLocale } from '../mastodon/load_locale';
import { loadLocale } from '../mastodon/locales';
import { loadPolyfills } from '../mastodon/polyfills';
start();
loadPolyfills().then(loadLocale).then(async () => {
const { default: main } = await import('mastodon/main');
return main();
}).catch(e => {
console.error(e);
});
loadPolyfills()
.then(loadLocale)
.then(main)
.catch(e => {
console.error(e);
});

View file

@ -15,8 +15,7 @@ import { start } from '../mastodon/common';
import { timeAgoString } from '../mastodon/components/relative_timestamp';
import emojify from '../mastodon/features/emoji/emoji';
import loadKeyboardExtensions from '../mastodon/load_keyboard_extensions';
import { loadLocale } from '../mastodon/load_locale';
import { getLocale } from '../mastodon/locales';
import { loadLocale, getLocale } from '../mastodon/locales';
import { loadPolyfills } from '../mastodon/polyfills';
import ready from '../mastodon/ready';

View file

@ -3,7 +3,6 @@ import { createRoot } from 'react-dom/client';
import { start } from '../mastodon/common';
import ComposeContainer from '../mastodon/containers/compose_container';
import { loadLocale } from '../mastodon/load_locale';
import { loadPolyfills } from '../mastodon/polyfills';
import ready from '../mastodon/ready';
@ -26,6 +25,6 @@ function main() {
ready(loaded);
}
loadPolyfills().then(loadLocale).then(main).catch(error => {
loadPolyfills().then(main).catch(error => {
console.error(error);
});