mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-07-30 22:48:30 +00:00
4.0.0 Beta 1
This commit is contained in:
parent
c2688646af
commit
262757a20d
187 changed files with 22878 additions and 38882 deletions
113
src/sites/twitch-twilight/index.js
Normal file
113
src/sites/twitch-twilight/index.js
Normal file
|
@ -0,0 +1,113 @@
|
|||
'use strict';
|
||||
|
||||
// ============================================================================
|
||||
// Site Support: Twitch Twilight
|
||||
// ============================================================================
|
||||
|
||||
import BaseSite from '../base';
|
||||
|
||||
import WebMunch from 'utilities/compat/webmunch';
|
||||
import Fine from 'utilities/compat/fine';
|
||||
import FineRouter from 'utilities/compat/fine-router';
|
||||
import Apollo from 'utilities/compat/apollo';
|
||||
|
||||
import {createElement as e} from 'utilities/dom';
|
||||
|
||||
import MAIN_URL from 'site/styles/main.scss';
|
||||
|
||||
|
||||
// ============================================================================
|
||||
// The Site
|
||||
// ============================================================================
|
||||
|
||||
export default class Twilight extends BaseSite {
|
||||
constructor(...args) {
|
||||
super(...args);
|
||||
|
||||
this.inject(WebMunch);
|
||||
this.inject(Fine);
|
||||
this.inject('router', FineRouter);
|
||||
this.inject(Apollo);
|
||||
}
|
||||
|
||||
onLoad() {
|
||||
this.populateModules();
|
||||
|
||||
this.web_munch.known(Twilight.KNOWN_MODULES);
|
||||
this.router.route(Twilight.ROUTES);
|
||||
}
|
||||
|
||||
onEnable() {
|
||||
const root = this.fine.getParent(this.fine.react),
|
||||
ctx = this.context = root && root._context,
|
||||
|
||||
store = this.store = ctx && ctx.store;
|
||||
|
||||
if ( ! store )
|
||||
return new Promise(r => setTimeout(r, 50)).then(() => this.onEnable());
|
||||
|
||||
// Share Context
|
||||
store.subscribe(() => this.updateContext());
|
||||
this.updateContext();
|
||||
|
||||
this.router.on(':route', (route, match) => {
|
||||
this.log.info('Navigation', route && route.name, match[0]);
|
||||
});
|
||||
|
||||
document.head.appendChild(e('link', {
|
||||
href: MAIN_URL,
|
||||
rel: 'stylesheet',
|
||||
type: 'text/css'
|
||||
}));
|
||||
}
|
||||
|
||||
updateContext() {
|
||||
const state = this.store.getState();
|
||||
this.settings.updateContext({
|
||||
location: state.router.location,
|
||||
|
||||
ui: state.ui,
|
||||
session: state.session
|
||||
});
|
||||
}
|
||||
|
||||
getSession() {
|
||||
const state = this.store && this.store.getState();
|
||||
return state && state.session;
|
||||
}
|
||||
|
||||
getUser() {
|
||||
const session = this.getSession();
|
||||
return session && session.user;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Twilight.KNOWN_MODULES = {
|
||||
simplebar: n => n.globalObserver && n.initDOMLoadedElements,
|
||||
react: n => n.Component && n.createElement,
|
||||
'extension-service': n => n.extensionService
|
||||
}
|
||||
|
||||
|
||||
Twilight.ROUTES = {
|
||||
'front-page': '/',
|
||||
'collection': '/collections/:collectionID',
|
||||
'dir-community': '/communities/:communityName',
|
||||
'dir-community-index': '/directory/communities',
|
||||
'dir-creative': '/directory/creative',
|
||||
'dir-following': '/directory/following/:category?',
|
||||
'dir-game-clips': '/directory/game/:gameName/clips',
|
||||
'dir-game-details': '/directory/game/:gameName/details',
|
||||
'dir-game-videos': '/directory/game/:gameName/videos/:filter',
|
||||
'dir-game-index': '/directory/game/:gameName',
|
||||
'dir-all': '/directory/all/:filter?',
|
||||
'dir-category': '/directory/:category?',
|
||||
'event': '/event/:eventName',
|
||||
'following': '/following',
|
||||
'popout': '/popout',
|
||||
'video': '/videos/:videoID',
|
||||
'user-videos': '/:userName/videos/:filter?',
|
||||
'user-clips': '/:userName/manager/clips',
|
||||
'user': '/:userName'
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue