mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-07-24 11:38:30 +00:00
Working on replacing the GraphQL dependency with a package we control.
This commit is contained in:
parent
4c9e67a22e
commit
0f07ac5c5b
9 changed files with 28 additions and 21 deletions
|
@ -37,6 +37,8 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"displacejs": "^1.2.4",
|
"displacejs": "^1.2.4",
|
||||||
|
"graphql": "^0.12.3",
|
||||||
|
"graphql-tag": "^2.6.1",
|
||||||
"path-to-regexp": "^2.1.0",
|
"path-to-regexp": "^2.1.0",
|
||||||
"popper.js": "^1.13.0",
|
"popper.js": "^1.13.0",
|
||||||
"sortablejs": "^1.7.0",
|
"sortablejs": "^1.7.0",
|
||||||
|
|
|
@ -300,6 +300,8 @@ export default class Badges extends Module {
|
||||||
style
|
style
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// TODO: Render styles for badges with overrides.
|
||||||
|
|
||||||
slotted[slot] = { id: badge.id, props };
|
slotted[slot] = { id: badge.id, props };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ export default class ChannelBar extends Module {
|
||||||
this.inject('metadata');
|
this.inject('metadata');
|
||||||
|
|
||||||
|
|
||||||
this.apollo.registerModifier('ChannelPage_ChannelInfoBar_User', `query {
|
this.apollo.registerModifier('ChannelPage_ChannelInfoBar_User', this.apollo.gql`query {
|
||||||
user {
|
user {
|
||||||
stream {
|
stream {
|
||||||
createdAt
|
createdAt
|
||||||
|
|
|
@ -15,7 +15,7 @@ export default class BrowsePopular extends SiteModule {
|
||||||
this.inject('site.fine');
|
this.inject('site.fine');
|
||||||
this.inject('settings');
|
this.inject('settings');
|
||||||
|
|
||||||
this.apollo.registerModifier('BrowsePage_Popular', `query {
|
this.apollo.registerModifier('BrowsePage_Popular', this.apollo.gql`query {
|
||||||
streams {
|
streams {
|
||||||
edges {
|
edges {
|
||||||
node {
|
node {
|
||||||
|
|
|
@ -12,7 +12,7 @@ export default class Community extends SiteModule {
|
||||||
|
|
||||||
this.inject('site.apollo');
|
this.inject('site.apollo');
|
||||||
|
|
||||||
this.apollo.registerModifier('GamePage_Game', `query {
|
this.apollo.registerModifier('GamePage_Game', this.apollo.gql`query {
|
||||||
directory {
|
directory {
|
||||||
... on Community {
|
... on Community {
|
||||||
streams {
|
streams {
|
||||||
|
|
|
@ -58,7 +58,7 @@ export default class Following extends SiteModule {
|
||||||
changed: () => this.ChannelCard.forceUpdate()
|
changed: () => this.ChannelCard.forceUpdate()
|
||||||
});
|
});
|
||||||
|
|
||||||
this.apollo.registerModifier('FollowedIndex_CurrentUser', `query {
|
this.apollo.registerModifier('FollowedIndex_CurrentUser', this.apollo.gql`query {
|
||||||
currentUser {
|
currentUser {
|
||||||
followedLiveUsers {
|
followedLiveUsers {
|
||||||
nodes {
|
nodes {
|
||||||
|
@ -83,7 +83,7 @@ export default class Following extends SiteModule {
|
||||||
}
|
}
|
||||||
}`);
|
}`);
|
||||||
|
|
||||||
this.apollo.registerModifier('FollowingLive_CurrentUser', `query {
|
this.apollo.registerModifier('FollowingLive_CurrentUser', this.apollo.gql`query {
|
||||||
currentUser {
|
currentUser {
|
||||||
followedLiveUsers {
|
followedLiveUsers {
|
||||||
edges {
|
edges {
|
||||||
|
@ -98,7 +98,7 @@ export default class Following extends SiteModule {
|
||||||
}
|
}
|
||||||
}`);
|
}`);
|
||||||
|
|
||||||
this.apollo.registerModifier('FollowingHosts_CurrentUser', `query {
|
this.apollo.registerModifier('FollowingHosts_CurrentUser', this.apollo.gql`query {
|
||||||
currentUser {
|
currentUser {
|
||||||
followedHosts {
|
followedHosts {
|
||||||
nodes {
|
nodes {
|
||||||
|
@ -114,7 +114,7 @@ export default class Following extends SiteModule {
|
||||||
}
|
}
|
||||||
}`);
|
}`);
|
||||||
|
|
||||||
this.apollo.registerModifier('FollowedChannels', `query {
|
this.apollo.registerModifier('FollowedChannels', this.apollo.gql`query {
|
||||||
currentUser {
|
currentUser {
|
||||||
followedLiveUsers {
|
followedLiveUsers {
|
||||||
nodes {
|
nodes {
|
||||||
|
|
|
@ -22,7 +22,7 @@ export default class Game extends SiteModule {
|
||||||
n => n.renderFollowButton && n.renderGameDetailsTab
|
n => n.renderFollowButton && n.renderGameDetailsTab
|
||||||
);
|
);
|
||||||
|
|
||||||
this.apollo.registerModifier('GamePage_Game', `query {
|
this.apollo.registerModifier('GamePage_Game', this.apollo.gql`query {
|
||||||
directory {
|
directory {
|
||||||
... on Game {
|
... on Game {
|
||||||
streams {
|
streams {
|
||||||
|
@ -53,7 +53,7 @@ export default class Game extends SiteModule {
|
||||||
const container = this.fine.getHostNode(inst);
|
const container = this.fine.getHostNode(inst);
|
||||||
if ( inst.props.directoryType !== 'GAMES' || ! container || ! container.querySelector )
|
if ( inst.props.directoryType !== 'GAMES' || ! container || ! container.querySelector )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const buttons = container.querySelector('div > div.tw-align-items-center'),
|
const buttons = container.querySelector('div > div.tw-align-items-center'),
|
||||||
ffz_buttons = buttons && buttons.querySelector('.ffz-buttons');
|
ffz_buttons = buttons && buttons.querySelector('.ffz-buttons');
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ export default class FollowingText extends SiteModule {
|
||||||
this.inject('site.apollo');
|
this.inject('site.apollo');
|
||||||
this.inject('i18n');
|
this.inject('i18n');
|
||||||
|
|
||||||
this.apollo.registerModifier('FollowedChannels', `query {
|
this.apollo.registerModifier('FollowedChannels', this.apollo.gql`query {
|
||||||
currentUser {
|
currentUser {
|
||||||
followedLiveUsers {
|
followedLiveUsers {
|
||||||
nodes {
|
nodes {
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
import Module from 'utilities/module';
|
import Module from 'utilities/module';
|
||||||
import {has, get} from 'utilities/object';
|
import {has, get} from 'utilities/object';
|
||||||
|
import gql from 'graphql-tag';
|
||||||
|
|
||||||
export default class Apollo extends Module {
|
export default class Apollo extends Module {
|
||||||
constructor(...args) {
|
constructor(...args) {
|
||||||
|
@ -15,10 +16,12 @@ export default class Apollo extends Module {
|
||||||
this.modifiers = {};
|
this.modifiers = {};
|
||||||
this.post_modifiers = {};
|
this.post_modifiers = {};
|
||||||
|
|
||||||
|
this.gql = gql;
|
||||||
|
|
||||||
this.inject('..web_munch');
|
this.inject('..web_munch');
|
||||||
this.inject('..fine');
|
this.inject('..fine');
|
||||||
|
|
||||||
this.registerModifier('ViewerCard', `query {
|
this.registerModifier('ViewerCard', gql`query {
|
||||||
targetUser: user {
|
targetUser: user {
|
||||||
createdAt
|
createdAt
|
||||||
profileViewCount
|
profileViewCount
|
||||||
|
@ -28,8 +31,8 @@ export default class Apollo extends Module {
|
||||||
|
|
||||||
async onEnable() {
|
async onEnable() {
|
||||||
// TODO: Come up with a better way to await something existing.
|
// TODO: Come up with a better way to await something existing.
|
||||||
let client = this.client,
|
let client = this.client;
|
||||||
graphql = this.graphql;
|
//graphql = this.graphql;
|
||||||
|
|
||||||
if ( ! client ) {
|
if ( ! client ) {
|
||||||
const root = this.fine.getParent(this.fine.react),
|
const root = this.fine.getParent(this.fine.react),
|
||||||
|
@ -38,14 +41,14 @@ export default class Apollo extends Module {
|
||||||
client = this.client = ctx && ctx.client;
|
client = this.client = ctx && ctx.client;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! graphql )
|
//if ( ! graphql )
|
||||||
graphql = this.graphql = await this.web_munch.findModule('graphql', m => m.parse && m.parseValue);
|
// graphql = this.graphql = await this.web_munch.findModule('graphql', m => m.parse && m.parseValue);
|
||||||
|
|
||||||
if ( ! client || ! graphql )
|
if ( ! client ) // || ! graphql )
|
||||||
return new Promise(s => setTimeout(s,50)).then(() => this.onEnable());
|
return new Promise(s => setTimeout(s,50)).then(() => this.onEnable());
|
||||||
|
|
||||||
// Parse the queries for modifiers that were already registered.
|
// Parse the queries for modifiers that were already registered.
|
||||||
for(const key in this.modifiers)
|
/*for(const key in this.modifiers)
|
||||||
if ( has(this.modifiers, key) ) {
|
if ( has(this.modifiers, key) ) {
|
||||||
const modifiers = this.modifiers[key];
|
const modifiers = this.modifiers[key];
|
||||||
if ( modifiers )
|
if ( modifiers )
|
||||||
|
@ -60,7 +63,7 @@ export default class Apollo extends Module {
|
||||||
mod[1] = false;
|
mod[1] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
// Register middleware so that we can intercept requests.
|
// Register middleware so that we can intercept requests.
|
||||||
this.client.networkInterface.use([{
|
this.client.networkInterface.use([{
|
||||||
|
@ -145,15 +148,15 @@ export default class Apollo extends Module {
|
||||||
if ( ! pre )
|
if ( ! pre )
|
||||||
throw new Error('post modifiers must be functions');
|
throw new Error('post modifiers must be functions');
|
||||||
|
|
||||||
let parsed;
|
/*let parsed;
|
||||||
try {
|
try {
|
||||||
parsed = this.graphql ? this.graphql.parse(modifier, {noLocation: true}) : null;
|
parsed = this.graphql ? this.graphql.parse(modifier, {noLocation: true}) : null;
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
this.log.error(`Error parsing GraphQL statement for "${operation}" modifier.`, err);
|
this.log.error(`Error parsing GraphQL statement for "${operation}" modifier.`, err);
|
||||||
parsed = false;
|
parsed = false;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
modifier = [modifier, parsed];
|
modifier = [modifier, modifier]; // parsed];
|
||||||
}
|
}
|
||||||
|
|
||||||
const mods = pre
|
const mods = pre
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue