mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-07-05 18:48:31 +00:00
Add support for minimal pages to Switchboard.
This commit is contained in:
parent
86c5fee033
commit
cbc862ac5a
3 changed files with 57 additions and 24 deletions
|
@ -1,4 +1,9 @@
|
|||
<div class="list-header">4.0.0-rc1.8<span>@498c1b079484a762958a</span> <time datetime="2018-05-18">(2018-05-18)</time></div>
|
||||
<div class="list-header">4.0.0-rc1.9<span>@d5a7ef61195e86dc7277</span> <time datetime="2018-05-18">(2018-05-18)</time></div>
|
||||
<ul class="chat-menu-content menu-side-padding">
|
||||
<li>Fixed: Add support for minimal root pages to the new webpack 4 code. They don't use the same router.</li>
|
||||
</ul>
|
||||
|
||||
<div class="list-header">4.0.0-rc1.8<span>@8254abfe4d4c824f58d6</span> <time datetime="2018-05-18">(2018-05-18)</time></div>
|
||||
<ul class="chat-menu-content menu-side-padding">
|
||||
<li>Changed: Finish writing support for webpack 4 support.</li>
|
||||
</ul>
|
||||
|
|
|
@ -100,7 +100,7 @@ class FrankerFaceZ extends Module {
|
|||
FrankerFaceZ.Logger = Logger;
|
||||
|
||||
const VER = FrankerFaceZ.version_info = {
|
||||
major: 4, minor: 0, revision: 0, extra: '-rc1.8',
|
||||
major: 4, minor: 0, revision: 0, extra: '-rc1.9',
|
||||
build: __webpack_hash__,
|
||||
toString: () =>
|
||||
`${VER.major}.${VER.minor}.${VER.revision}${VER.extra || ''}${DEBUG ? '-dev' : ''}`
|
||||
|
|
|
@ -14,39 +14,30 @@ export default class Switchboard extends Module {
|
|||
|
||||
this.inject('site.web_munch');
|
||||
this.inject('site.fine');
|
||||
|
||||
this.RootRouter = this.fine.define(
|
||||
'root-router',
|
||||
n => n && n.logger && n.logger.category === 'default-root-router'
|
||||
);
|
||||
this.inject('site.router');
|
||||
}
|
||||
|
||||
|
||||
awaitRouter() {
|
||||
const router = this.RootRouter.first;
|
||||
const router = this.fine.searchTree(null, n => n.logger && n.logger.category === 'default-root-router', 100);
|
||||
if ( router )
|
||||
return Promise.resolve(router);
|
||||
|
||||
return new Promise(resolve => {
|
||||
this.RootRouter.ready(() => resolve(this.RootRouter.first))
|
||||
});
|
||||
return new Promise(r => setTimeout(r, 50)).then(() => this.awaitRouter());
|
||||
}
|
||||
|
||||
|
||||
async onEnable() {
|
||||
const router = await this.awaitRouter(),
|
||||
child = router && this.fine.getFirstChild(router),
|
||||
da_switch = child && child.stateNode;
|
||||
awaitMinimalRouter() {
|
||||
const router = this.fine.searchTree(null, n => n.onHistoryChange && n.reportInteractive);
|
||||
if ( router )
|
||||
return Promise.resolve(router);
|
||||
|
||||
if ( this.web_munch.v4 === false )
|
||||
return;
|
||||
return new Promise(r => setTimeout(r, 50)).then(() => this.awaitMinimalRouter());
|
||||
}
|
||||
|
||||
if ( ! da_switch )
|
||||
return new Promise(r => setTimeout(r, 50)).then(() => this.onEnable());
|
||||
|
||||
const real_context = da_switch.context,
|
||||
on_settings = real_context.router.route.location.pathname.includes('settings');
|
||||
|
||||
hijinx(da_switch, path) {
|
||||
const real_context = da_switch.context;
|
||||
let output;
|
||||
|
||||
try {
|
||||
|
@ -54,11 +45,11 @@ export default class Switchboard extends Module {
|
|||
router: {
|
||||
route: {
|
||||
location: {
|
||||
pathname: on_settings ? '/inventory' : '/settings'
|
||||
pathname: path
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
output = da_switch.render();
|
||||
|
||||
|
@ -90,4 +81,41 @@ export default class Switchboard extends Module {
|
|||
this.log.warn('Unexpected result trying to use component loader to force loading of another chunk.', err);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async onEnable() {
|
||||
const root = await this.parent.awaitElement('.twilight-minimal-root,.twilight-root'),
|
||||
is_minimal = root && root.classList.contains('twilight-minimal-root');
|
||||
|
||||
if ( this.web_munch._require || this.web_munch.v4 === false )
|
||||
return;
|
||||
|
||||
if ( is_minimal )
|
||||
return this.enableMinimal();
|
||||
|
||||
const router = await this.awaitRouter(),
|
||||
child = router && this.fine.getFirstChild(router),
|
||||
da_switch = child && child.stateNode;
|
||||
|
||||
if ( ! da_switch )
|
||||
return new Promise(r => setTimeout(r, 50)).then(() => this.onEnable());
|
||||
|
||||
const on_settings = da_switch.context.router.route.location.pathname.includes('settings');
|
||||
return this.hijinx(da_switch, on_settings ? '/inventory' : '/settings');
|
||||
}
|
||||
|
||||
|
||||
async enableMinimal() {
|
||||
const router = await this.awaitMinimalRouter(),
|
||||
da_switch = router && this.fine.searchTree(router, n => n.context && n.context.router);
|
||||
|
||||
if ( this.web_munch._require || this.web_munch.v4 === false )
|
||||
return;
|
||||
|
||||
if ( ! da_switch )
|
||||
return new Promise(r => setTimeout(r, 50)).then(() => this.enableMinimal());
|
||||
|
||||
const on_prime = da_switch.context.router.route.location.pathname.includes('prime');
|
||||
return this.hijinx(da_switch, on_prime ? '/subs' : '/prime')
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue