finish public servers
This commit is contained in:
parent
6aa1dd3f28
commit
7d3403d79a
36
css/main.css
36
css/main.css
|
@ -134,6 +134,42 @@
|
|||
}
|
||||
|
||||
|
||||
.bd-server-card {
|
||||
position: relative;
|
||||
border-width: 1px;
|
||||
border-style: solid;
|
||||
border-radius: 5px;
|
||||
background: rgba(32,34,37,.6);
|
||||
border-color: #202225;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.bd-server-header,
|
||||
.bd-server-footer {
|
||||
display: flex;
|
||||
color: #b9bbbe;
|
||||
}
|
||||
|
||||
.bd-server-header {
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
.bd-server-card .bd-button {
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.bd-button.bd-button-success {
|
||||
background-color: #3ac15c;
|
||||
}
|
||||
|
||||
.bd-button.bd-button-success:hover {
|
||||
background-color: rgb(52,174,83);
|
||||
}
|
||||
|
||||
.bd-button.bd-button-success:active {
|
||||
background-color: rgb(46,154,74);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
44
js/main.js
44
js/main.js
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,4 +1,5 @@
|
|||
import Builtin from "../structs/builtin";
|
||||
import PSConnection from "./publicservers/connection";
|
||||
import {BDV2, DiscordModules, WebpackModules} from "modules";
|
||||
import {PublicServersMenu} from "ui";
|
||||
|
||||
|
@ -20,7 +21,7 @@ export default new class PublicServers extends Builtin {
|
|||
}
|
||||
|
||||
openPublicServers() {
|
||||
LayerStack.pushLayer(() => DiscordModules.React.createElement(PublicServersMenu, {close: LayerStack.popLayer}));
|
||||
LayerStack.pushLayer(() => DiscordModules.React.createElement(PublicServersMenu, {close: LayerStack.popLayer, connection: PSConnection}));
|
||||
}
|
||||
|
||||
get button() {
|
||||
|
|
|
@ -109,8 +109,8 @@ export default class PublicServersConnection {
|
|||
|
||||
static get windowOptions() {
|
||||
return {
|
||||
width: 500,
|
||||
height: 550,
|
||||
width: 380,
|
||||
height: 450,
|
||||
backgroundColor: "#282b30",
|
||||
show: true,
|
||||
resizable: true,
|
|
@ -85,7 +85,8 @@ export default class Logger {
|
|||
static _log(module, message, type = "log") {
|
||||
type = Logger.parseType(type);
|
||||
if (!Array.isArray(message)) message = [message];
|
||||
console[type](`%c[BandagedBD]%c %c[${module}]%c`, "color: #3E82E5; font-weight: 700;", "color: #3a71c1;", "", ...message);
|
||||
console[type](`%c[BandagedBD]%c [${module}]%c`, "color: #3E82E5; font-weight: 700;", "color: #3a71c1;", "", ...message);
|
||||
//console.log(`%c[BandagedBD]%c [${moduleName}]%c ${message}`, "color: #3a71c1; font-weight: 700;", "color: #3a71c1;", "");
|
||||
}
|
||||
|
||||
static parseType(type) {
|
||||
|
|
|
@ -1,102 +0,0 @@
|
|||
import {React} from "modules";
|
||||
import Manager from "./manager";
|
||||
|
||||
export default class ServerCard extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
if (!this.props.server.iconUrl) this.props.server.iconUrl = Manager.getDefaultAvatar();
|
||||
this.state = {
|
||||
imageError: false,
|
||||
joined: Manager.hasJoined(this.props.server.identifier)
|
||||
};
|
||||
}
|
||||
|
||||
render() {
|
||||
const {server} = this.props;
|
||||
return React.createElement(
|
||||
"div", // cardPrimary-1Hv-to
|
||||
{className: `card-3Qj_Yx cardPrimary-1Hv-to marginBottom8-AtZOdT bd-server-card${server.pinned ? " bd-server-card-pinned" : ""}`},
|
||||
React.createElement("img", {ref: "img", className: "bd-server-image", src: server.iconUrl, onError: this.handleError.bind(this)}),
|
||||
React.createElement(
|
||||
"div",
|
||||
{className: "flexChild-faoVW3 bd-server-content"},
|
||||
React.createElement(
|
||||
"div",
|
||||
{className: "flex-1xMQg5 flex-1O1GKY horizontal-1ae9ci horizontal-2EEEnY directionRow-3v3tfG noWrap-3jynv6 bd-server-header"},
|
||||
React.createElement(
|
||||
"h5",
|
||||
{className: "h5-18_1nd defaultColor-1_ajX0 margin-reset bd-server-name"},
|
||||
server.name
|
||||
),
|
||||
React.createElement(
|
||||
"h5",
|
||||
{className: "h5-18_1nd defaultColor-1_ajX0 margin-reset bd-server-member-count"},
|
||||
server.members,
|
||||
" Members"
|
||||
)
|
||||
),
|
||||
React.createElement(
|
||||
"div",
|
||||
{className: "flex-1xMQg5 flex-1O1GKY horizontal-1ae9ci horizontal-2EEEnY directionRow-3v3tfG noWrap-3jynv6"},
|
||||
React.createElement(
|
||||
"div",
|
||||
{className: "scrollerWrap-2lJEkd scrollerThemed-2oenus themeGhostHairline-DBD-2d scrollerFade-1Ijw5y bd-server-description-container"},
|
||||
React.createElement(
|
||||
"div",
|
||||
{className: "scroller-2FKFPG scroller bd-server-description"},
|
||||
server.description
|
||||
)
|
||||
)
|
||||
),
|
||||
React.createElement(
|
||||
"div",
|
||||
{className: "flex-1xMQg5 flex-1O1GKY horizontal-1ae9ci horizontal-2EEEnY directionRow-3v3tfG noWrap-3jynv6 bd-server-footer"},
|
||||
React.createElement(
|
||||
"div",
|
||||
{className: "flexChild-faoVW3 bd-server-tags", style: {flex: "1 1 auto"}},
|
||||
server.categories.join(", ")
|
||||
),
|
||||
this.state.joined && React.createElement(
|
||||
"button",
|
||||
{type: "button", className: "bd-button button-38aScr lookFilled-1Gx00P colorBrand-3pXr91 sizeMin-1mJd1x grow-q77ONN colorGreen-29iAKY", style: {minHeight: "12px", marginTop: "4px", backgroundColor: "#3ac15c"}},
|
||||
React.createElement(
|
||||
"div",
|
||||
{className: "ui-button-contents"},
|
||||
typeof(this.state.joined) == "string" ? "Joining..." : "Joined"
|
||||
)
|
||||
),
|
||||
server.error && React.createElement(
|
||||
"button",
|
||||
{type: "button", className: "bd-button button-38aScr lookFilled-1Gx00P colorBrand-3pXr91 sizeMin-1mJd1x grow-q77ONN disabled-9aF2ug", style: {minHeight: "12px", marginTop: "4px", backgroundColor: "#c13a3a"}},
|
||||
React.createElement(
|
||||
"div",
|
||||
{className: "ui-button-contents"},
|
||||
"Error"
|
||||
)
|
||||
),
|
||||
!server.error && !this.state.joined && React.createElement(
|
||||
"button",
|
||||
{type: "button", className: "bd-button button-38aScr lookFilled-1Gx00P colorBrand-3pXr91 sizeMin-1mJd1x grow-q77ONN", style: {minHeight: "12px", marginTop: "4px"}, onClick: () => {this.join();}},
|
||||
React.createElement(
|
||||
"div",
|
||||
{className: "ui-button-contents"},
|
||||
"Join"
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
// )
|
||||
);
|
||||
}
|
||||
|
||||
handleError() {
|
||||
this.props.server.iconUrl = Manager.getDefaultAvatar();
|
||||
this.setState({imageError: true});
|
||||
}
|
||||
|
||||
async join() {
|
||||
this.setState({joined: "joining"});
|
||||
const didJoin = await Manager.join(this.props.server.identifier, this.props.server.nativejoin);
|
||||
this.setState({joined: didJoin});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
import {React} from "modules";
|
||||
|
||||
export default class ServerCard extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
if (!this.props.server.iconUrl) this.props.server.iconUrl = this.props.defaultAvatar();
|
||||
this.state = {
|
||||
imageError: false,
|
||||
joined: this.props.joined
|
||||
};
|
||||
this.join = this.join.bind(this);
|
||||
this.handleError = this.handleError.bind(this);
|
||||
}
|
||||
|
||||
render() {
|
||||
const {server} = this.props;
|
||||
const buttonText = typeof(this.state.joined) == "string" ? "Joining..." : this.state.joined ? "Joined" : "Join";
|
||||
const buttonClass = `bd-button${this.state.joined == true ? " bd-button-success" : ""}`;
|
||||
return <div className={`bd-server-card${server.pinned ? " bd-server-card-pinned" : ""}`}>
|
||||
<img className="bd-server-image" src={server.iconUrl} onError={this.handleError} />,
|
||||
<div className="bd-server-content">
|
||||
<div className="bd-server-header">
|
||||
<h5 className="bd-server-name">{server.name}</h5>
|
||||
<h5 className="bd-server-member-count">{server.members} Members</h5>
|
||||
</div>
|
||||
<div className="bd-scroller-wrap bd-server-description-container">
|
||||
<div className="bd-scroller bd-server-description">{server.description}</div>
|
||||
</div>
|
||||
<div className="bd-server-footer">
|
||||
<div className="bd-server-tags">{server.categories.join(", ")}</div>
|
||||
<button type="button" className={buttonClass} onClick={this.join}>{buttonText}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>;
|
||||
}
|
||||
|
||||
handleError() {
|
||||
this.props.server.iconUrl = this.props.defaultAvatar();
|
||||
this.setState({imageError: true});
|
||||
}
|
||||
|
||||
async join() {
|
||||
if (this.state.joined) return;
|
||||
this.setState({joined: "joining"});
|
||||
const didJoin = await this.props.join(this.props.server.identifier, this.props.server.nativejoin);
|
||||
this.setState({joined: didJoin});
|
||||
}
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
import {React, WebpackModules} from "modules";
|
||||
import SettingsTitle from "../settings/title";
|
||||
import ServerCard from "./card";
|
||||
import Manager from "./manager";
|
||||
|
||||
const SettingsView = WebpackModules.getByDisplayName("SettingsView");
|
||||
|
||||
|
@ -38,7 +37,7 @@ export default class PublicServers extends React.Component {
|
|||
}
|
||||
|
||||
async checkConnection() {
|
||||
const userData = await Manager.checkConnection();
|
||||
const userData = await this.props.connection.checkConnection();
|
||||
if (!userData) {
|
||||
return this.setState({loading: true, user: null});
|
||||
}
|
||||
|
@ -47,7 +46,7 @@ export default class PublicServers extends React.Component {
|
|||
}
|
||||
|
||||
async connect() {
|
||||
await Manager.connect();
|
||||
await this.props.connection.connect();
|
||||
this.checkConnection();
|
||||
}
|
||||
|
||||
|
@ -58,7 +57,7 @@ export default class PublicServers extends React.Component {
|
|||
|
||||
async search(term = "", from = 0) {
|
||||
this.setState({query: term, loading: true});
|
||||
const results = await Manager.search({term, category: this.state.category == "All" ? "" : this.state.category, from});
|
||||
const results = await this.props.connection.search({term, category: this.state.category == "All" ? "" : this.state.category, from});
|
||||
if (!results) {
|
||||
return this.setState({results: {
|
||||
servers: [],
|
||||
|
@ -82,8 +81,12 @@ export default class PublicServers extends React.Component {
|
|||
this.search(this.state.query, this.state.results.next);
|
||||
}
|
||||
|
||||
async join(id, native = false) {
|
||||
return await this.props.connection.join(id, native);
|
||||
}
|
||||
|
||||
get searchBox() {
|
||||
return React.createElement("input", {onKeyDown: this.searchKeyDown, type: "text", className: "bd-search", placeholder: "Search...", value: this.state.query, maxLength: "50"});
|
||||
return React.createElement("input", {onKeyDown: this.searchKeyDown, type: "text", className: "bd-search", placeholder: "Search...", maxLength: "50"});
|
||||
}
|
||||
|
||||
get title() {
|
||||
|
@ -101,7 +104,7 @@ export default class PublicServers extends React.Component {
|
|||
const connectButton = this.state.user ? null : {title: "Connect", onClick: this.connect};
|
||||
const pinned = this.state.category == "All" || !this.state.user ? this.bdServer : null;
|
||||
const servers = this.state.results.servers.map((server) => {
|
||||
return React.createElement(ServerCard, {key: server.identifier, server: server});
|
||||
return React.createElement(ServerCard, {key: server.identifier, server: server, joined: this.props.connection.hasJoined(server.identifier), defaultAvatar: this.props.connection.getDefaultAvatar});
|
||||
});
|
||||
return [React.createElement(SettingsTitle, {text: this.title, button: connectButton}),
|
||||
pinned,
|
||||
|
@ -136,7 +139,7 @@ export default class PublicServers extends React.Component {
|
|||
invite_code: "0Tmfo5ZbORCRqbAd",
|
||||
pinned: true
|
||||
};
|
||||
return React.createElement(ServerCard, {server: server, pinned: true});
|
||||
return React.createElement(ServerCard, {server: server, pinned: true, joined: this.props.connection.hasJoined(server.identifier), defaultAvatar: this.props.connection.getDefaultAvatar});
|
||||
}
|
||||
|
||||
render() {
|
||||
|
|
|
@ -1,427 +0,0 @@
|
|||
import {React, WebpackModules} from "modules";
|
||||
import SettingsTitle from "../settings/title";
|
||||
import ServerCard from "./card";
|
||||
|
||||
const AvatarDefaults = WebpackModules.getByProps("getUserAvatarURL", "DEFAULT_AVATARS");
|
||||
const InviteActions = WebpackModules.getByProps("acceptInvite");
|
||||
const SortedGuildStore = WebpackModules.getByProps("getSortedGuilds");
|
||||
//SettingsView
|
||||
//onClose pop layer
|
||||
//onSetSection dispatch user settings modal set section section subsection
|
||||
//section selected one
|
||||
//sections []
|
||||
//theme dark
|
||||
|
||||
|
||||
const StandardSidebarView = WebpackModules.getByDisplayName("StandardSidebarView");
|
||||
//WebpackModules.getByDisplayName("StandardSidebarView")
|
||||
//sidebar = WebpackModules.getByDisplayName("TabBar")
|
||||
// children []
|
||||
// sidebar.Header
|
||||
// sidebar.Item
|
||||
// sidebar.Separator
|
||||
// onItemSelect
|
||||
// selectedItem
|
||||
//section = "All"
|
||||
//theme = "dark"
|
||||
//content = this.content
|
||||
//closeAction = pop probably
|
||||
|
||||
|
||||
export default class PublicServers extends React.Component {
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
selectedCategory: "All",
|
||||
title: "Loading...",
|
||||
loading: true,
|
||||
servers: [],
|
||||
next: null,
|
||||
connection: {
|
||||
state: 0,
|
||||
user: null
|
||||
}
|
||||
};
|
||||
this.close = this.close.bind(this);
|
||||
this.changeCategory = this.changeCategory.bind(this);
|
||||
this.search = this.search.bind(this);
|
||||
this.searchKeyDown = this.searchKeyDown.bind(this);
|
||||
this.checkConnection = this.checkConnection.bind(this);
|
||||
this.join = this.join.bind(this);
|
||||
this.connect = this.connect.bind(this);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.checkConnection();
|
||||
}
|
||||
|
||||
close() {
|
||||
this.props.close();
|
||||
}
|
||||
|
||||
search(query, clear) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: `${this.endPoint}${query}${query ? "&schema=new" : "?schema=new"}`,
|
||||
success: data => {
|
||||
let servers = data.results.reduce((arr, server) => {
|
||||
server.joined = false;
|
||||
arr.push(server);
|
||||
// arr.push(<ServerCard server={server} join={this.join}/>);
|
||||
return arr;
|
||||
}, []);
|
||||
|
||||
if (!clear) {
|
||||
servers = this.state.servers.concat(servers);
|
||||
}
|
||||
else {
|
||||
//servers.unshift(this.bdServer);
|
||||
}
|
||||
|
||||
console.log(data);
|
||||
|
||||
let end = data.size + data.from;
|
||||
data.next = `?from=${end}`;
|
||||
if (this.state.term) data.next += `&term=${this.state.term}`;
|
||||
if (this.state.selectedCategory) data.next += `&category=${this.state.selectedCategory}`;
|
||||
if (end >= data.total) {
|
||||
end = data.total;
|
||||
data.next = null;
|
||||
}
|
||||
|
||||
let title = `Showing 1-${end} of ${data.total} results in ${this.state.selectedCategory}`;
|
||||
if (this.state.term) title += ` for ${this.state.term}`;
|
||||
|
||||
this.setState({
|
||||
loading: false,
|
||||
title: title,
|
||||
servers: servers,
|
||||
next: data.next
|
||||
});
|
||||
|
||||
if (clear) {
|
||||
//console.log(this);
|
||||
// this.refs.sbv.refs.contentScroller.scrollTop = 0;
|
||||
}
|
||||
},
|
||||
error: () => {
|
||||
this.setState({
|
||||
loading: false,
|
||||
title: "Failed to load servers. Check console for details"
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
join(serverCard) {
|
||||
if (serverCard.props.pinned) return InviteActions.acceptInvite(serverCard.props.invite_code);
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: `${this.joinEndPoint}/${serverCard.props.server.identifier}`,
|
||||
headers: {
|
||||
"Accept": "application/json;",
|
||||
"Content-Type": "application/json;" ,
|
||||
"x-discord-token": this.state.connection.user.accessToken
|
||||
},
|
||||
crossDomain: true,
|
||||
xhrFields: {
|
||||
withCredentials: true
|
||||
},
|
||||
success: () => {
|
||||
serverCard.setState({joined: true});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
connect() {
|
||||
const options = this.windowOptions;
|
||||
options.x = Math.round(window.screenX + window.innerWidth / 2 - options.width / 2);
|
||||
options.y = Math.round(window.screenY + window.innerHeight / 2 - options.height / 2);
|
||||
|
||||
this.joinWindow = new (window.require("electron").remote.BrowserWindow)(options);
|
||||
const url = "https://auth.discordservers.com/connect?scopes=guilds.join&previousUrl=https://auth.discordservers.com/info";
|
||||
this.joinWindow.webContents.on("did-navigate", (event, navUrl) => {
|
||||
if (navUrl != "https://auth.discordservers.com/info") return;
|
||||
this.joinWindow.close();
|
||||
this.checkConnection();
|
||||
});
|
||||
this.joinWindow.loadURL(url);
|
||||
}
|
||||
|
||||
get windowOptions() {
|
||||
return {
|
||||
width: 500,
|
||||
height: 550,
|
||||
backgroundColor: "#282b30",
|
||||
show: true,
|
||||
resizable: false,
|
||||
maximizable: false,
|
||||
minimizable: false,
|
||||
alwaysOnTop: true,
|
||||
frame: false,
|
||||
center: false,
|
||||
webPreferences: {
|
||||
nodeIntegration: false
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
get bdServer() {
|
||||
const server = {
|
||||
name: "BetterDiscord",
|
||||
online: "7500+",
|
||||
members: "20000+",
|
||||
categories: ["community", "programming", "support"],
|
||||
description: "Official BetterDiscord server for support etc",
|
||||
identifier: "86004744966914048",
|
||||
iconUrl: "https://cdn.discordapp.com/icons/86004744966914048/292e7f6bfff2b71dfd13e508a859aedd.webp",
|
||||
nativejoin: true,
|
||||
invite_code: "0Tmfo5ZbORCRqbAd",
|
||||
pinned: true
|
||||
};
|
||||
const guildList = SortedGuildStore.guildPositions;
|
||||
const defaultList = AvatarDefaults.DEFAULT_AVATARS;
|
||||
return React.createElement(ServerCard, {server: server, pinned: true, join: this.join, guildList: guildList, fallback: defaultList[Math.floor(Math.random() * 5)]});
|
||||
}
|
||||
|
||||
get endPoint() {
|
||||
return "https://search.discordservers.com";
|
||||
}
|
||||
|
||||
get joinEndPoint() {
|
||||
return "https://j.discordservers.com";
|
||||
}
|
||||
|
||||
get connectEndPoint() {
|
||||
return "https://join.discordservers.com/connect";
|
||||
}
|
||||
|
||||
checkConnection() {
|
||||
try {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: `https://auth.discordservers.com/info`,
|
||||
headers: {
|
||||
"Accept": "application/json;",
|
||||
"Content-Type": "application/json;"
|
||||
},
|
||||
crossDomain: true,
|
||||
xhrFields: {
|
||||
withCredentials: true
|
||||
},
|
||||
success: data => {
|
||||
// Utils.log("PublicServer", "Got data: " + JSON.stringify(data));
|
||||
this.setState({
|
||||
selectedCategory: "All",
|
||||
connection: {
|
||||
state: 2,
|
||||
user: data
|
||||
}
|
||||
});
|
||||
this.search("", true);
|
||||
|
||||
},
|
||||
error: () => {
|
||||
this.setState({
|
||||
title: "Not connected to discordservers.com!",
|
||||
loading: true,
|
||||
selectedCategory: "All",
|
||||
connection: {
|
||||
state: 1,
|
||||
user: null
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (error) {
|
||||
this.setState({
|
||||
title: "Not connected to discordservers.com!",
|
||||
loading: true,
|
||||
selectedCategory: "All",
|
||||
connection: {
|
||||
state: 1,
|
||||
user: null
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//WebpackModules.getByDisplayName("StandardSidebarView")
|
||||
//sidebar = WebpackModules.getByDisplayName("TabBar")
|
||||
// children []
|
||||
// sidebar.Header
|
||||
// sidebar.Item
|
||||
// sidebar.Separator
|
||||
// onItemSelect
|
||||
// selectedItem
|
||||
//section = "All"
|
||||
//theme = "dark"
|
||||
//content = this.content
|
||||
//closeAction = pop probably
|
||||
render() {
|
||||
return React.createElement(StandardSidebarView, {
|
||||
closeAction: this.close,
|
||||
section: this.state.selectedCategory,
|
||||
content: this.content,
|
||||
sidebar: this.sidebar,
|
||||
theme: "dark"
|
||||
});
|
||||
}
|
||||
|
||||
get sidebar() {
|
||||
const TabBar = WebpackModules.getByDisplayName("TabBar");
|
||||
const categories = this.categoryButtons.map(name =>
|
||||
React.createElement(TabBar.Item, {id: name}, name)
|
||||
);
|
||||
return React.createElement(TabBar, {onItemSelect: (category) => this.changeCategory(category), selectedItem: this.state.selectedCategory},
|
||||
React.createElement(TabBar.Header, null, "Search"),
|
||||
this.searchInput,
|
||||
React.createElement(TabBar.Header, null, "Categories"),
|
||||
categories,
|
||||
React.createElement(TabBar.Separator),
|
||||
React.createElement(TabBar.Header, null, React.createElement("a", {href: "https://discordservers.com", target: "_blank"}, "Discordservers.com")),
|
||||
React.createElement(TabBar.Separator),
|
||||
this.connection
|
||||
);
|
||||
}
|
||||
|
||||
get searchInput() {
|
||||
return React.createElement(
|
||||
"div",
|
||||
{className: "ui-form-item"},
|
||||
React.createElement(
|
||||
"div",
|
||||
{className: "ui-text-input flex-vertical", style: {width: "172px", marginLeft: "10px"}},
|
||||
React.createElement("input", {onKeyDown: this.searchKeyDown, onChange: () => {}, type: "text", className: "input default", placeholder: "Search...", maxLength: "50"})
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
searchKeyDown(e) {
|
||||
if (this.state.loading || e.which !== 13) return;
|
||||
this.setState({
|
||||
loading: true,
|
||||
title: "Loading...",
|
||||
term: e.target.value
|
||||
});
|
||||
let query = `?term=${e.target.value}`;
|
||||
if (this.state.selectedCategory !== "All") {
|
||||
query += `&category=${this.state.selectedCategory}`;
|
||||
}
|
||||
this.search(query, true);
|
||||
}
|
||||
|
||||
get categoryButtons() {
|
||||
return ["All", "FPS Games", "MMO Games", "Strategy Games", "MOBA Games", "RPG Games", "Tabletop Games", "Sandbox Games", "Simulation Games", "Music", "Community", "Language", "Programming", "Other"];
|
||||
}
|
||||
|
||||
changeCategory(id) {
|
||||
if (this.state.loading) return;
|
||||
// this.refs.searchinput.value = "";
|
||||
this.setState({
|
||||
loading: true,
|
||||
selectedCategory: id,
|
||||
title: "Loading...",
|
||||
term: null
|
||||
});
|
||||
if (id === "All") {
|
||||
this.search("", true);
|
||||
return;
|
||||
}
|
||||
this.search(`?category=${this.state.selectedCategory.replace(" ", "%20")}`, true);
|
||||
}
|
||||
|
||||
get content() {
|
||||
const guildList = SortedGuildStore.guildPositions;
|
||||
const defaultList = AvatarDefaults.DEFAULT_AVATARS;
|
||||
if (this.state.connection.state === 1) return this.notConnected;
|
||||
return [React.createElement(SettingsTitle, {text: this.state.title}),
|
||||
this.state.selectedCategory == "All" && this.bdServer,
|
||||
this.state.servers.map((server) => {
|
||||
return React.createElement(ServerCard, {key: server.identifier, server: server, join: this.join, guildList: guildList, fallback: defaultList[Math.floor(Math.random() * 5)]});
|
||||
}),
|
||||
this.state.next && React.createElement(
|
||||
"button",
|
||||
{type: "button", onClick: () => {
|
||||
if (this.state.loading) return;this.setState({loading: true}); this.search(this.state.next, false);
|
||||
}, className: "ui-button filled brand small grow", style: {width: "100%", marginTop: "10px", marginBottom: "10px"}},
|
||||
React.createElement(
|
||||
"div",
|
||||
{className: "ui-button-contents"},
|
||||
this.state.loading ? "Loading" : "Load More"
|
||||
)
|
||||
),
|
||||
this.state.servers.length > 0 && React.createElement(SettingsTitle, {text: this.state.title})];
|
||||
}
|
||||
|
||||
get notConnected() {
|
||||
//return React.createElement(SettingsTitle, { text: this.state.title });
|
||||
return [React.createElement(
|
||||
"h2",
|
||||
{className: "ui-form-title h2 margin-reset margin-bottom-20"},
|
||||
"Not connected to discordservers.com!",
|
||||
React.createElement(
|
||||
"button",
|
||||
{
|
||||
onClick: this.connect,
|
||||
type: "button",
|
||||
className: "ui-button filled brand small grow",
|
||||
style: {
|
||||
display: "inline-block",
|
||||
minHeight: "18px",
|
||||
marginLeft: "10px",
|
||||
lineHeight: "14px"
|
||||
}
|
||||
},
|
||||
React.createElement(
|
||||
"div",
|
||||
{className: "ui-button-contents"},
|
||||
"Connect"
|
||||
)
|
||||
)
|
||||
), this.bdServer];
|
||||
}
|
||||
|
||||
get footer() {
|
||||
return React.createElement(
|
||||
"div",
|
||||
{className: "ui-tab-bar-header"},
|
||||
React.createElement(
|
||||
"a",
|
||||
{href: "https://discordservers.com", target: "_blank"},
|
||||
"Discordservers.com"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
get connection() {
|
||||
const {connection} = this.state;
|
||||
if (connection.state !== 2) return React.createElement("span", null);
|
||||
|
||||
return React.createElement(
|
||||
"span",
|
||||
null,
|
||||
React.createElement(
|
||||
"span",
|
||||
{style: {color: "#b9bbbe", fontSize: "10px", marginLeft: "10px"}},
|
||||
"Connected as: ",
|
||||
`${connection.user.username}#${connection.user.discriminator}`
|
||||
),
|
||||
React.createElement(
|
||||
"div",
|
||||
{style: {padding: "5px 10px 0 10px"}},
|
||||
React.createElement(
|
||||
"button",
|
||||
{style: {width: "100%", minHeight: "20px"}, type: "button", className: "ui-button filled brand small grow"},
|
||||
React.createElement(
|
||||
"div",
|
||||
{className: "ui-button-contents", onClick: this.connect},
|
||||
"Reconnect"
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
|
@ -118,7 +118,6 @@ export default class PluginCard extends React.Component {
|
|||
|
||||
onChange() {
|
||||
this.setState({checked: !this.state.checked});
|
||||
// PluginManager.togglePlugin(this.props.content.id);
|
||||
this.props.onChange && this.props.onChange(this.props.content.id);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,15 +29,9 @@ export default class V2_SettingsPanel {
|
|||
}
|
||||
|
||||
static get attribution() {
|
||||
return React.createElement(
|
||||
"div",
|
||||
{style: {fontSize: "12px", fontWeight: "600", color: "#72767d", padding: "2px 10px"}},
|
||||
return React.createElement("div", {className: "bd-version", style: {fontSize: "12px", fontWeight: "600", color: "#72767d", padding: "2px 10px"}},
|
||||
`BBD v${Config.bbdVersion} by `,
|
||||
React.createElement(
|
||||
"a",
|
||||
{href: "https://github.com/rauenzi/", target: "_blank"},
|
||||
"Zerebos"
|
||||
)
|
||||
React.createElement("a", {href: "https://github.com/rauenzi/", target: "_blank"}, "Zerebos")
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue