stuff
This commit is contained in:
parent
e447a18556
commit
6a2d63907d
Plugins
|
@ -10987,30 +10987,22 @@
|
|||
}
|
||||
};
|
||||
|
||||
const BDFDB_Patrons_T2 = [
|
||||
"363785301195358221", // TRENT
|
||||
"106938698938978304", // GABRIEL
|
||||
"174868361040232448" // GIBBU
|
||||
];
|
||||
const BDFDB_Patrons_T3 = [
|
||||
"443943393660239872", // SARGE (PaSh)
|
||||
"329018006371827713", // FUSL
|
||||
"562008872467038230" // BEAUDEN
|
||||
];
|
||||
const BDFDB_Patrons_T3_hasBadge = [
|
||||
"562008872467038230" // BEAUDEN
|
||||
];
|
||||
const BDFDB_Patrons = {
|
||||
"363785301195358221": {active:true, t3:false, custom:false}, // TRENT
|
||||
"106938698938978304": {active:true, t3:false, custom:false}, // GABRIEL
|
||||
"174868361040232448": {active:false, t3:false, custom:false}, // GIBBU
|
||||
"443943393660239872": {active:true, t3:true, custom:false}, // SARGE (PaSh)
|
||||
"329018006371827713": {active:true, t3:true, custom:false}, // FUSL
|
||||
"562008872467038230": {active:false, t3:true, custom:true} // BEAUDEN
|
||||
};
|
||||
InternalBDFDB._processAvatarRender = function (user, avatar) {
|
||||
if (BDFDB.ReactUtils.isValidElement(avatar) && BDFDB.ObjectUtils.is(user)) {
|
||||
avatar.props["user_by_BDFDB"] = user.id;
|
||||
let role = "", className = BDFDB.DOMUtils.formatClassName((avatar.props.className || "").replace(BDFDB.disCN.avatar, "")), addBadge = settings.showSupportBadges;
|
||||
if (BDFDB_Patrons_T2.includes(user.id)) {
|
||||
role = "BDFDB Patron";
|
||||
className = BDFDB.DOMUtils.formatClassName(className, addBadge && BDFDB.disCN.bdfdbhasbadge, BDFDB.disCN.bdfdbbadgeavatar, BDFDB.disCN.bdfdbsupporter);
|
||||
}
|
||||
if (BDFDB_Patrons_T3.includes(user.id)) {
|
||||
role = "BDFDB Patron Level 2";
|
||||
className = BDFDB.DOMUtils.formatClassName(className, addBadge && BDFDB.disCN.bdfdbhasbadge, BDFDB.disCN.bdfdbbadgeavatar, BDFDB.disCN.bdfdbsupporter, addBadge && BDFDB_Patrons_T3_hasBadge.includes(user.id) && BDFDB.disCN.bdfdbsupportercustom);
|
||||
let role = "", className = BDFDB.DOMUtils.formatClassName((avatar.props.className || "").replace(BDFDB.disCN.avatar, "")), addBadge = settings.showSupportBadges, customBadge = false;
|
||||
if (BDFDB_Patrons[user.id] && BDFDB_Patrons[user.id].active) {
|
||||
role = BDFDB_Patrons[user.id].t3 ? "BDFDB Patron Level 2" : "BDFDB Patron";
|
||||
customBadge = addBadge && BDFDB_Patrons[user.id].t3 && BDFDB_Patrons[user.id].custom;
|
||||
className = BDFDB.DOMUtils.formatClassName(className, addBadge && BDFDB.disCN.bdfdbhasbadge, BDFDB.disCN.bdfdbbadgeavatar, BDFDB.disCN.bdfdbsupporter, customBadge && BDFDB.disCN.bdfdbsupportercustom);
|
||||
}
|
||||
if (user.id == myId) {
|
||||
addBadge = true;
|
||||
|
@ -11026,14 +11018,14 @@
|
|||
avatar = BDFDB.ReactUtils.createElement("div", {
|
||||
className: className,
|
||||
style: {borderRadius: 0, overflow: "visible"},
|
||||
"custombadge_id": BDFDB_Patrons_T3_hasBadge.includes(user.id) ? user.id : null,
|
||||
"custombadge_id": customBadge ? user.id : null,
|
||||
"user_by_BDFDB": user.id,
|
||||
children: [avatar]
|
||||
});
|
||||
if (addBadge) avatar.props.children.push(BDFDB.ReactUtils.createElement(InternalComponents.LibraryComponents.TooltipContainer, {
|
||||
text: role,
|
||||
children: BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN.bdfdbbadge,
|
||||
className: BDFDB.disCN.bdfdbbadge
|
||||
})
|
||||
}));
|
||||
return avatar;
|
||||
|
@ -11044,15 +11036,11 @@
|
|||
if (Node.prototype.isPrototypeOf(avatar) && BDFDB.ObjectUtils.is(user)) {
|
||||
if (wrapper) wrapper.setAttribute("user_by_BDFDB", user.id);
|
||||
avatar.setAttribute("user_by_BDFDB", user.id);
|
||||
let role = "", addBadge = settings.showSupportBadges;;
|
||||
if (BDFDB_Patrons_T2.includes(user.id) && addBadge) {
|
||||
role = "BDFDB Patron";
|
||||
avatar.className = BDFDB.DOMUtils.formatClassName(avatar.className, addBadge && BDFDB.disCN.bdfdbhasbadge, BDFDB.disCN.bdfdbbadgeavatar, BDFDB.disCN.bdfdbsupporter);
|
||||
}
|
||||
else if (BDFDB_Patrons_T3.includes(user.id) && addBadge) {
|
||||
role = "BDFDB Patron Level 2";
|
||||
avatar.className = BDFDB.DOMUtils.formatClassName(avatar.className, addBadge && BDFDB.disCN.bdfdbhasbadge, BDFDB.disCN.bdfdbbadgeavatar, BDFDB.disCN.bdfdbsupporter, addBadge && BDFDB_Patrons_T3_hasBadge.includes(user.id) && BDFDB.disCN.bdfdbsupportercustom);
|
||||
|
||||
let role = "", addBadge = settings.showSupportBadges, customBadge = false;
|
||||
if (BDFDB_Patrons[user.id] && BDFDB_Patrons[user.id].active) {
|
||||
role = BDFDB_Patrons[user.id].t3 ? "BDFDB Patron Level 2" : "BDFDB Patron";
|
||||
customBadge = addBadge && BDFDB_Patrons[user.id].t3 && BDFDB_Patrons[user.id].custom;
|
||||
avatar.className = BDFDB.DOMUtils.formatClassName(avatar.className, addBadge && BDFDB.disCN.bdfdbhasbadge, BDFDB.disCN.bdfdbbadgeavatar, BDFDB.disCN.bdfdbsupporter, customBadge && BDFDB.disCN.bdfdbsupportercustom);
|
||||
}
|
||||
else if (user.id == myId) {
|
||||
addBadge = true;
|
||||
|
@ -11061,7 +11049,7 @@
|
|||
}
|
||||
if (role && !avatar.querySelector(BDFDB.dotCN.bdfdbbadge)) {
|
||||
if (addBadge) {
|
||||
if (BDFDB_Patrons_T3_hasBadge.includes(user.id)) avatar.setAttribute("custombadge_id", user.id);
|
||||
if (customBadge) avatar.setAttribute("custombadge_id", user.id);
|
||||
let badge = document.createElement("div");
|
||||
badge.className = BDFDB.disCN.bdfdbbadge;
|
||||
badge.addEventListener("mouseenter", _ => {BDFDB.TooltipUtils.create(badge, role, {position: "top"});});
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -96,90 +96,12 @@ var PluginRepo = (_ => {
|
|||
if (this.props.orderKey == "DESC") plugins.reverse();
|
||||
return plugins;
|
||||
}
|
||||
renderCard(plugin) {
|
||||
let buttonConfig = buttonData[(Object.entries(pluginStates).find(n => n[1] == plugin.state) || [])[0]];
|
||||
return buttonConfig && BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.AddonCard, {
|
||||
data: plugin,
|
||||
controls: [
|
||||
plugin.new == newStates.NEW && BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Badges.TextBadge, {
|
||||
style: {
|
||||
borderRadius: 3,
|
||||
textTransform: "uppercase",
|
||||
background: BDFDB.DiscordConstants.Colors.STATUS_YELLOW
|
||||
},
|
||||
text: BDFDB.LanguageUtils.LanguageStrings.NEW
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FavButton, {
|
||||
className: BDFDB.disCN._repocontrolsbutton,
|
||||
isFavorite: plugin.fav == favStates.FAVORIZED,
|
||||
onClick: value => {
|
||||
plugin.fav = value ? favStates.FAVORIZED : favStates.NOT_FAVORIZED;
|
||||
if (value) favorites.push(plugin.url);
|
||||
else BDFDB.ArrayUtils.remove(favorites, plugin.url, true);
|
||||
BDFDB.DataUtils.save(favorites, _this, "favorites");
|
||||
}
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN._repocontrolsbutton,
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
|
||||
text: "Go to Source",
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
|
||||
name: BDFDB.LibraryComponents.SvgIcon.Names.GITHUB,
|
||||
className: BDFDB.disCN._repoicon,
|
||||
onClick: _ => {
|
||||
let gitUrl = null;
|
||||
if (plugin.url.indexOf("https://raw.githubusercontent.com") == 0) {
|
||||
let temp = plugin.url.replace("//raw.githubusercontent", "//github").split("/");
|
||||
temp.splice(5, 0, "blob");
|
||||
gitUrl = temp.join("/");
|
||||
}
|
||||
else if (plugin.url.indexOf("https://gist.githubusercontent.com/") == 0) {
|
||||
gitUrl = plugin.url.replace("//gist.githubusercontent", "//gist.github").split("/raw/")[0];
|
||||
}
|
||||
if (gitUrl) BDFDB.DiscordUtils.openLink(gitUrl, settings.useChromium);
|
||||
}
|
||||
})
|
||||
})
|
||||
}),
|
||||
],
|
||||
buttons: [
|
||||
plugin.state != pluginStates.DOWNLOADABLE && BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN._repocontrolsbutton,
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
|
||||
text: "Delete Pluginfile",
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
|
||||
name: BDFDB.LibraryComponents.SvgIcon.Names.NOVA_TRASH,
|
||||
className: BDFDB.disCN._repoicon,
|
||||
onClick: (e, instance) => {
|
||||
_this.stopPlugin(plugin);
|
||||
_this.deletePluginFile(plugin);
|
||||
BDFDB.TimeUtils.timeout(_ => {
|
||||
BDFDB.ReactUtils.forceUpdate(this);
|
||||
}, 3000);
|
||||
}
|
||||
})
|
||||
})
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Button, {
|
||||
size: BDFDB.LibraryComponents.Button.Sizes.MIN,
|
||||
color: BDFDB.LibraryComponents.Button.Colors[buttonConfig.colorClass],
|
||||
style: {backgroundColor: BDFDB.DiscordConstants.Colors[buttonConfig.backgroundColor]},
|
||||
children: buttonConfig.text,
|
||||
onClick: (e, instance) => {
|
||||
_this.downloadPlugin(plugin);
|
||||
BDFDB.TimeUtils.timeout(_ => {
|
||||
BDFDB.ReactUtils.forceUpdate(this);
|
||||
if (this.props.rnmStart) _this.startPlugin(plugin);
|
||||
}, 3000);
|
||||
}
|
||||
})
|
||||
]
|
||||
});
|
||||
}
|
||||
render() {
|
||||
let automaticLoading = BDFDB.BDUtils.getSettings(BDFDB.BDUtils.settingsIds.automaticLoading);
|
||||
if (!this.props.tab) this.props.tab = "Plugins";
|
||||
this.props.entries = (!loading.is && !BDFDB.ObjectUtils.isEmpty(loadedPlugins) ? this.filterPlugins() : []).map(plugin => this.renderCard(plugin)).filter(n => n);
|
||||
this.props.entries = (!loading.is && !BDFDB.ObjectUtils.isEmpty(loadedPlugins) ? this.filterPlugins() : []).map(plugin => BDFDB.ReactUtils.createElement(RepoCardComponent, {
|
||||
plugin: plugin
|
||||
})).filter(n => n);
|
||||
|
||||
BDFDB.TimeUtils.timeout(_ => {
|
||||
if (!loading.is && header && this.props.entries.length != header.props.amount) {
|
||||
|
@ -250,6 +172,89 @@ var PluginRepo = (_ => {
|
|||
}
|
||||
};
|
||||
|
||||
const RepoCardComponent = class PluginCard extends BdApi.React.Component {
|
||||
render() {
|
||||
let buttonConfig = buttonData[(Object.entries(pluginStates).find(n => n[1] == this.props.plugin.state) || [])[0]];
|
||||
return buttonConfig && BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.AddonCard, {
|
||||
data: this.props.plugin,
|
||||
controls: [
|
||||
this.props.plugin.new == newStates.NEW && BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Badges.TextBadge, {
|
||||
style: {
|
||||
borderRadius: 3,
|
||||
textTransform: "uppercase",
|
||||
background: BDFDB.DiscordConstants.Colors.STATUS_YELLOW
|
||||
},
|
||||
text: BDFDB.LanguageUtils.LanguageStrings.NEW
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FavButton, {
|
||||
className: BDFDB.disCN._repocontrolsbutton,
|
||||
isFavorite: this.props.plugin.fav == favStates.FAVORIZED,
|
||||
onClick: value => {
|
||||
this.props.plugin.fav = value ? favStates.FAVORIZED : favStates.NOT_FAVORIZED;
|
||||
if (value) favorites.push(this.props.plugin.url);
|
||||
else BDFDB.ArrayUtils.remove(favorites, this.props.plugin.url, true);
|
||||
BDFDB.DataUtils.save(favorites, _this, "favorites");
|
||||
}
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN._repocontrolsbutton,
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
|
||||
text: "Go to Source",
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
|
||||
name: BDFDB.LibraryComponents.SvgIcon.Names.GITHUB,
|
||||
className: BDFDB.disCN._repoicon,
|
||||
onClick: _ => {
|
||||
let gitUrl = null;
|
||||
if (this.props.plugin.url.indexOf("https://raw.githubusercontent.com") == 0) {
|
||||
let temp = this.props.plugin.url.replace("//raw.githubusercontent", "//github").split("/");
|
||||
temp.splice(5, 0, "blob");
|
||||
gitUrl = temp.join("/");
|
||||
}
|
||||
else if (this.props.plugin.url.indexOf("https://gist.githubusercontent.com/") == 0) {
|
||||
gitUrl = this.props.plugin.url.replace("//gist.githubusercontent", "//gist.github").split("/raw/")[0];
|
||||
}
|
||||
if (gitUrl) BDFDB.DiscordUtils.openLink(gitUrl, settings.useChromium);
|
||||
}
|
||||
})
|
||||
})
|
||||
}),
|
||||
],
|
||||
buttons: [
|
||||
this.props.plugin.state != pluginStates.DOWNLOADABLE && BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN._repocontrolsbutton,
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
|
||||
text: "Delete Pluginfile",
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
|
||||
name: BDFDB.LibraryComponents.SvgIcon.Names.NOVA_TRASH,
|
||||
className: BDFDB.disCN._repoicon,
|
||||
onClick: (e, instance) => {
|
||||
_this.stopPlugin(this.props.plugin);
|
||||
_this.deletePluginFile(this.props.plugin);
|
||||
this.props.plugin.state = pluginStates.DOWNLOADABLE;
|
||||
BDFDB.ReactUtils.forceUpdate(this);
|
||||
}
|
||||
})
|
||||
})
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Button, {
|
||||
size: BDFDB.LibraryComponents.Button.Sizes.MIN,
|
||||
color: BDFDB.LibraryComponents.Button.Colors[buttonConfig.colorClass],
|
||||
style: {backgroundColor: BDFDB.DiscordConstants.Colors[buttonConfig.backgroundColor]},
|
||||
children: buttonConfig.text,
|
||||
onClick: (e, instance) => {
|
||||
_this.downloadPlugin(this.props.plugin);
|
||||
if (list && list.props.rnmStart) BDFDB.TimeUtils.timeout(_ => {
|
||||
if (this.props.plugin.state == pluginStates.UPDATED) _this.startPlugin(this.props.plugin);
|
||||
}, 3000);
|
||||
this.props.plugin.state = pluginStates.UPDATED;
|
||||
BDFDB.ReactUtils.forceUpdate(this);
|
||||
}
|
||||
})
|
||||
]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const RepoListHeaderComponent = class PluginListHeader extends BdApi.React.Component {
|
||||
componentDidMount() {
|
||||
header = this;
|
||||
|
@ -348,7 +353,7 @@ var PluginRepo = (_ => {
|
|||
return class PluginRepo {
|
||||
getName () {return "PluginRepo";}
|
||||
|
||||
getVersion () {return "2.0.4";}
|
||||
getVersion () {return "2.0.6";}
|
||||
|
||||
getAuthor () {return "DevilBro";}
|
||||
|
||||
|
@ -356,7 +361,7 @@ var PluginRepo = (_ => {
|
|||
|
||||
constructor () {
|
||||
this.changelog = {
|
||||
"improved":[["Inbuilt Repo","The plugin repo no longer opens a modal to display the repo, instead the list is rendered in the settings window"]]
|
||||
"fixed":[["Auto Enable","No longer tries to start plugins twice"]]
|
||||
};
|
||||
|
||||
this.patchedModules = {
|
||||
|
|
|
@ -164,107 +164,12 @@ var ThemeRepo = (_ => {
|
|||
}
|
||||
});
|
||||
}
|
||||
renderCard(theme) {
|
||||
let buttonConfig = buttonData[(Object.entries(themeStates).find(n => n[1] == theme.state) || [])[0]];
|
||||
return buttonConfig && BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.AddonCard, {
|
||||
data: theme,
|
||||
controls: [
|
||||
theme.new == newStates.NEW && BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Badges.TextBadge, {
|
||||
style: {
|
||||
borderRadius: 3,
|
||||
textTransform: "uppercase",
|
||||
background: BDFDB.DiscordConstants.Colors.STATUS_YELLOW
|
||||
},
|
||||
text: BDFDB.LanguageUtils.LanguageStrings.NEW
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FavButton, {
|
||||
className: BDFDB.disCN._repocontrolsbutton,
|
||||
isFavorite: theme.fav == favStates.FAVORIZED,
|
||||
onClick: value => {
|
||||
theme.fav = value ? favStates.FAVORIZED : favStates.NOT_FAVORIZED;
|
||||
if (value) favorites.push(theme.url);
|
||||
else BDFDB.ArrayUtils.remove(favorites, theme.url, true);
|
||||
BDFDB.DataUtils.save(favorites, _this, "favorites");
|
||||
}
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN._repocontrolsbutton,
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
|
||||
text: "Go to Source",
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
|
||||
name: BDFDB.LibraryComponents.SvgIcon.Names.GITHUB,
|
||||
className: BDFDB.disCN._repoicon,
|
||||
onClick: _ => {
|
||||
let gitUrl = null;
|
||||
if (theme.url.indexOf("https://raw.githubusercontent.com") == 0) {
|
||||
let temp = theme.url.replace("//raw.githubusercontent", "//github").split("/");
|
||||
temp.splice(5, 0, "blob");
|
||||
gitUrl = temp.join("/");
|
||||
}
|
||||
else if (theme.url.indexOf("https://gist.githubusercontent.com/") == 0) {
|
||||
gitUrl = theme.url.replace("//gist.githubusercontent", "//gist.github").split("/raw/")[0];
|
||||
}
|
||||
if (gitUrl) BDFDB.DiscordUtils.openLink(gitUrl, settings.useChromium);
|
||||
}
|
||||
})
|
||||
})
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Switch, {
|
||||
value: this.props.currentTheme && this.props.currentTheme.url == theme.url,
|
||||
onChange: (value, instance) => {
|
||||
if (value) this.props.currentTheme = theme;
|
||||
else delete this.props.currentTheme;
|
||||
delete this.props.currentGenerator;
|
||||
delete this.props.generatorValues;
|
||||
if (preview) preview.executeJavaScriptSafe(`window.onmessage({
|
||||
origin: "ThemeRepo",
|
||||
reason: "NewTheme",
|
||||
checked: ${value},
|
||||
css: ${JSON.stringify(theme.css || "")}
|
||||
})`);
|
||||
else this.openPreview();
|
||||
BDFDB.ReactUtils.forceUpdate(this);
|
||||
}
|
||||
})
|
||||
],
|
||||
buttons: [
|
||||
theme.state != themeStates.DOWNLOADABLE && BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN._repocontrolsbutton,
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
|
||||
text: "Delete Themefile",
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
|
||||
name: BDFDB.LibraryComponents.SvgIcon.Names.NOVA_TRASH,
|
||||
className: BDFDB.disCN._repoicon,
|
||||
onClick: (e, instance) => {
|
||||
_this.removeTheme(theme);
|
||||
_this.deleteThemeFile(theme);
|
||||
BDFDB.TimeUtils.timeout(_ => {
|
||||
BDFDB.ReactUtils.forceUpdate(this);
|
||||
}, 3000);
|
||||
}
|
||||
})
|
||||
})
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Button, {
|
||||
size: BDFDB.LibraryComponents.Button.Sizes.MIN,
|
||||
color: BDFDB.LibraryComponents.Button.Colors[buttonConfig.colorClass],
|
||||
style: {backgroundColor: BDFDB.DiscordConstants.Colors[buttonConfig.backgroundColor]},
|
||||
children: buttonConfig.text,
|
||||
onClick: (e, instance) => {
|
||||
_this.downloadTheme(theme);
|
||||
BDFDB.TimeUtils.timeout(_ => {
|
||||
BDFDB.ReactUtils.forceUpdate(this);
|
||||
if (this.props.rnmStart) _this.applyTheme(theme);
|
||||
}, 3000);
|
||||
}
|
||||
})
|
||||
]
|
||||
});
|
||||
}
|
||||
render() {
|
||||
let automaticLoading = BDFDB.BDUtils.getSettings(BDFDB.BDUtils.settingsIds.automaticLoading);
|
||||
if (!this.props.tab) this.props.tab = "Themes";
|
||||
this.props.entries = (!loading.is && !BDFDB.ObjectUtils.isEmpty(loadedThemes) ? this.filterThemes() : []).map(theme => this.renderCard(theme)).filter(n => n);
|
||||
this.props.entries = (!loading.is && !BDFDB.ObjectUtils.isEmpty(loadedThemes) ? this.filterThemes() : []).map(theme => BDFDB.ReactUtils.createElement(RepoCardComponent, {
|
||||
theme: theme
|
||||
})).filter(n => n);
|
||||
|
||||
BDFDB.TimeUtils.timeout(_ => {
|
||||
if (!loading.is && header && this.props.entries.length != header.props.amount) {
|
||||
|
@ -533,6 +438,107 @@ var ThemeRepo = (_ => {
|
|||
}
|
||||
};
|
||||
|
||||
const RepoCardComponent = class ThemeCard extends BdApi.React.Component {
|
||||
render() {
|
||||
let buttonConfig = buttonData[(Object.entries(themeStates).find(n => n[1] == this.props.theme.state) || [])[0]];
|
||||
return buttonConfig && BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.AddonCard, {
|
||||
data: this.props.theme,
|
||||
controls: [
|
||||
this.props.theme.new == newStates.NEW && BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Badges.TextBadge, {
|
||||
style: {
|
||||
borderRadius: 3,
|
||||
textTransform: "uppercase",
|
||||
background: BDFDB.DiscordConstants.Colors.STATUS_YELLOW
|
||||
},
|
||||
text: BDFDB.LanguageUtils.LanguageStrings.NEW
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FavButton, {
|
||||
className: BDFDB.disCN._repocontrolsbutton,
|
||||
isFavorite: this.props.theme.fav == favStates.FAVORIZED,
|
||||
onClick: value => {
|
||||
this.props.theme.fav = value ? favStates.FAVORIZED : favStates.NOT_FAVORIZED;
|
||||
if (value) favorites.push(this.props.theme.url);
|
||||
else BDFDB.ArrayUtils.remove(favorites, this.props.theme.url, true);
|
||||
BDFDB.DataUtils.save(favorites, _this, "favorites");
|
||||
}
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN._repocontrolsbutton,
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
|
||||
text: "Go to Source",
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
|
||||
name: BDFDB.LibraryComponents.SvgIcon.Names.GITHUB,
|
||||
className: BDFDB.disCN._repoicon,
|
||||
onClick: _ => {
|
||||
let gitUrl = null;
|
||||
if (this.props.theme.url.indexOf("https://raw.githubusercontent.com") == 0) {
|
||||
let temp = this.props.theme.url.replace("//raw.githubusercontent", "//github").split("/");
|
||||
temp.splice(5, 0, "blob");
|
||||
gitUrl = temp.join("/");
|
||||
}
|
||||
else if (this.props.theme.url.indexOf("https://gist.githubusercontent.com/") == 0) {
|
||||
gitUrl = this.props.theme.url.replace("//gist.githubusercontent", "//gist.github").split("/raw/")[0];
|
||||
}
|
||||
if (gitUrl) BDFDB.DiscordUtils.openLink(gitUrl, settings.useChromium);
|
||||
}
|
||||
})
|
||||
})
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Switch, {
|
||||
value: list && list.props.currentTheme && list.props.currentTheme.url == this.props.theme.url,
|
||||
onChange: (value, instance) => {
|
||||
if (!list) return;
|
||||
if (value) list.props.currentTheme = this.props.theme;
|
||||
else delete list.props.currentTheme;
|
||||
delete list.props.currentGenerator;
|
||||
delete list.props.generatorValues;
|
||||
if (preview) preview.executeJavaScriptSafe(`window.onmessage({
|
||||
origin: "ThemeRepo",
|
||||
reason: "NewTheme",
|
||||
checked: ${value},
|
||||
css: ${JSON.stringify(this.props.theme.css || "")}
|
||||
})`);
|
||||
else list.openPreview();
|
||||
BDFDB.ReactUtils.forceUpdate(this);
|
||||
}
|
||||
})
|
||||
],
|
||||
buttons: [
|
||||
this.props.theme.state != themeStates.DOWNLOADABLE && BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN._repocontrolsbutton,
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
|
||||
text: "Delete Themefile",
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
|
||||
name: BDFDB.LibraryComponents.SvgIcon.Names.NOVA_TRASH,
|
||||
className: BDFDB.disCN._repoicon,
|
||||
onClick: (e, instance) => {
|
||||
_this.removeTheme(this.props.theme);
|
||||
_this.deleteThemeFile(this.props.theme);
|
||||
this.props.theme.state = themeStates.DOWNLOADABLE;
|
||||
BDFDB.ReactUtils.forceUpdate(this);
|
||||
}
|
||||
})
|
||||
})
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Button, {
|
||||
size: BDFDB.LibraryComponents.Button.Sizes.MIN,
|
||||
color: BDFDB.LibraryComponents.Button.Colors[buttonConfig.colorClass],
|
||||
style: {backgroundColor: BDFDB.DiscordConstants.Colors[buttonConfig.backgroundColor]},
|
||||
children: buttonConfig.text,
|
||||
onClick: (e, instance) => {
|
||||
_this.downloadTheme(this.props.theme);
|
||||
if (list && list.props.rnmStart) BDFDB.TimeUtils.timeout(_ => {
|
||||
if (this.props.theme.state == themeStates.UPDATED) _this.applyTheme(this.props.theme);
|
||||
}, 3000);
|
||||
this.props.theme.state = themeStates.UPDATED;
|
||||
BDFDB.ReactUtils.forceUpdate(this);
|
||||
}
|
||||
})
|
||||
]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const RepoListHeaderComponent = class ThemeListHeader extends BdApi.React.Component {
|
||||
componentDidMount() {
|
||||
header = this;
|
||||
|
@ -631,7 +637,7 @@ var ThemeRepo = (_ => {
|
|||
return class ThemeRepo {
|
||||
getName () {return "ThemeRepo";}
|
||||
|
||||
getVersion () {return "2.0.5";}
|
||||
getVersion () {return "2.0.6";}
|
||||
|
||||
getAuthor () {return "DevilBro";}
|
||||
|
||||
|
@ -639,7 +645,7 @@ var ThemeRepo = (_ => {
|
|||
|
||||
constructor () {
|
||||
this.changelog = {
|
||||
"fixed":[["Generator","Theme Generator works again"]]
|
||||
"fixed":[["Auto Enable","No longer adds two copies of the theme"]]
|
||||
};
|
||||
|
||||
this.patchedModules = {
|
||||
|
@ -1147,7 +1153,6 @@ var ThemeRepo = (_ => {
|
|||
if (data.name && BDFDB.BDUtils.isThemeEnabled(data.name) == false) {
|
||||
let id = data.name.replace(/^[^a-z]+|[^\w-]+/gi, "-");
|
||||
BDFDB.DOMUtils.remove(`style#${id}`);
|
||||
document.head.appendChild(BDFDB.DOMUtils.create(`<style id=${id}>${data.css}</style>`));
|
||||
BDFDB.BDUtils.enableTheme(data.name, false);
|
||||
BDFDB.LogUtils.log(`Applied Theme ${data.name}.`, this.name);
|
||||
}
|
||||
|
|
|
@ -105,9 +105,6 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="REPLACE_CLASS_guildouter" id="bd-pub-li" style="">
|
||||
<div class="REPLACE_CLASS_guildinner REPLACE_CLASS_guildbuttoncontainer" id="bd-pub-button">public</div>
|
||||
</div>
|
||||
<div style="opacity: 1; height: 56px; transform: scale(1);">
|
||||
<div class="REPLACE_CLASS_guildouter">
|
||||
<div class="REPLACE_CLASS_dmpill REPLACE_CLASS_guildpillwrapper">
|
||||
|
|
Loading…
Reference in New Issue