mirror of
https://github.com/flarum/framework.git
synced 2024-11-24 18:41:10 +08:00
9bfb797fdc
- All custom JS variables are now preloaded into the `app.data` object, rather than directly on the `app` object. This means that admin settings are available in `app.data.settings` rather than `app.settings`, etc. - Cleaner route handler generation - Renamed ConfigureClientView to ConfigureWebApp, though the former still exists and is deprecated - Partial fix for #881 (strips ?nojs=1 from URL if possible, so that refreshing will attempt to load JS version again)
25 lines
798 B
JavaScript
25 lines
798 B
JavaScript
import Session from 'flarum/Session';
|
|
|
|
/**
|
|
* The `preload` initializer creates the application session and preloads it
|
|
* with data that has been set on the application's `preload` property. It also
|
|
* preloads any data on the application's `preload` property into the store.
|
|
* Finally, it sets the application's `forum` instance to the one that was
|
|
* preloaded.
|
|
*
|
|
* `app.preload.session` should be the same as the response from the /api/token
|
|
* endpoint: it should contain `token` and `userId` keys.
|
|
*
|
|
* @param {App} app
|
|
*/
|
|
export default function preload(app) {
|
|
app.store.pushPayload({data: app.data.resources});
|
|
|
|
app.forum = app.store.getById('forums', 1);
|
|
|
|
app.session = new Session(
|
|
app.store.getById('users', app.data.session.userId),
|
|
app.data.session.csrfToken
|
|
);
|
|
}
|