An object that manages the state of active alerts.
Whether or not the app has been booted.
A local cache that can be used to store data at the application level, so that is persists between different routes.
An object which controls the state of the composer.
The page the app is currently on.
This object holds information about the type of page we are currently visiting, and sometimes additional arbitrary page state that may be relevant to lower-level components.
InternalcurrentProtecteddeferredGET requests that failed because the browser was offline, keyed by method, URL and params. They are retried, and their original promises settled, once connectivity is restored. Identical requests (e.g. from a polling extension) share one entry and are retried only once.
An object which controls the state of the cached discussion list, which is used in the index page and the slideout pane.
An object that manages the state of the navigation drawer.
The forum model for this application.
The app's history stack, which keeps track of which routes the user visits so that they can easily navigate back to the previous route.
An ordered list of initializers to bootstrap the application.
An object that manages modal state.
ProtectednetworkThe key for the Alert that was shown as a result of an AJAX request failing at the network level (status 0). Unlike other request error alerts, only one of these is shown at a time.
A map of notification types to their components.
An object which controls the state of the user's notifications.
ProtectedofflineThe key for the Alert that is shown while the browser reports being offline.
An object which controls the state of the page's side pane.
A map of post types to their components.
An ordered list of chunk loaders to prefetch once the app is idle after booting.
Lazily-loaded (code-split) components add a network round-trip the first time their route is visited. Registering their loader here warms the chunk in the background so that, by the time the user navigates to it, the dynamic import resolves from cache instead of blocking on a request.
Each item is a thunk that triggers the load — a function returning the dynamic import of the chunk (the same loader passed to a lazy route).
The page the app was on before the current page.
Once the application navigates to another page, the object previously assigned to this.current will be moved to this.previous, while this.current is re-initialized.
Construct a URL to the route with the given name.
A map of routes, keyed by a unique route name. Each route is an object containing the following properties:
path The path that the route is accessed at.component The Mithril component to render when this route is active.An object which stores the global search state and manages search capabilities.
The app's session.
Stores info about the current user.
The app's data store.
The app's translator.
When the server reports an asset revision (on an API response) that differs from the one this page booted with, the forum's JS/CSS has been rebuilt since load. Prompt the user to reload to pick up the new assets, at most once.
Both values are produced server-side (see AssetsRevision), so they are
directly comparable regardless of which versioner the forum uses.
Public so the realtime extension can call it with a pushed revision token.
ProtectedconnectionWhether an alert about a connection problem (a network-level request failure or the browser being offline) is currently being shown.
ProtectedconnectionShow a persistent (but dismissible) alert while the browser reports being offline.
ProtectedconnectionDismiss any connection problem alerts, retry requests that were deferred while offline, and briefly confirm to the user that connectivity has been restored.
ProtecteddeferredThe identity of a request for deferral purposes: requests with the same key are considered identical and are retried only once.
ProtecteddeferHold a request that failed while offline. The returned promise settles with the result of retrying the request once connectivity is restored.
ProtectedinitializeGet the API response document that has been preloaded into the application.
Get the API response document that has been preloaded into the application.
ProtectedregisterRegister listeners to proactively notify the user when the browser goes offline and when connectivity is restored.
Make an AJAX request, handling any low-level errors that may occur.
ProtectedrequestBy default, show an error alert, and log the error to the console.
ProtectedrequestProtectedrequestProtectedUsed to modify the error message shown on the page to help troubleshooting. While not certain, a failing cross-origin request likely indicates a missing redirect to Flarum canonical URL. Because XHR errors do not expose CORS information, we can only compare the requested URL origin to the page origin.
ProtectedrunDetermine the current screen mode, based on our media queries.
Set the <title> of the page.
New page title
Set a number to display in the <title> of the page.
Number to display in title
ProtectedshouldWhether a failed request should be held back and retried once connectivity is restored, instead of being rejected.
Only GET requests that failed at the network level while the browser
reported being offline qualify: they are safe to repeat, and the
online event provides a reliable signal to retry them.
ProtectedtransformCheck whether or not the user is currently viewing a discussion.
ProtectedwatchWhen the icons come from a Kit or CDN, they hold a blank placeholder font
until the remote stylesheet arrives. The backend wires a rescue — rebinding
the icons to the bundled fonts — to onerror on the remote tags, but some
failures never produce an error event: a kit script that loads fine while
its own stylesheet request is blocked, or a connection that hangs rather
than dying. This watchdog covers those. Firing by mistake is harmless: the
remote faces are declared later than the rescued ones whenever they do turn
up, so the icons simply upgrade in place.
The
Appclass provides a container for an application, as well as various utilities for the rest of the app to use.