Update ThemeRepo.plugin.js
This commit is contained in:
parent
183a744e08
commit
94a1cf5baf
|
@ -2,7 +2,7 @@
|
|||
* @name ThemeRepo
|
||||
* @author DevilBro
|
||||
* @authorId 278543574059057154
|
||||
* @version 2.3.9
|
||||
* @version 2.4.0
|
||||
* @description Allows you to download all Themes from BD's Website within Discord
|
||||
* @invite Jx3TjNS
|
||||
* @donate https://www.paypal.me/MircoWittrien
|
||||
|
@ -58,7 +58,7 @@ module.exports = (_ => {
|
|||
} : (([Plugin, BDFDB]) => {
|
||||
var _this;
|
||||
|
||||
var list, header;
|
||||
var list;
|
||||
|
||||
var loading, cachedThemes, grabbedThemes, generatorThemes, updateInterval;
|
||||
var searchString, searchTimeout, forcedSort, forcedOrder, showOnlyOutdated;
|
||||
|
@ -186,19 +186,118 @@ module.exports = (_ => {
|
|||
data: theme
|
||||
})).filter(n => n);
|
||||
|
||||
BDFDB.TimeUtils.timeout(_ => {
|
||||
if (!loading.is && header && this.props.entries.length != header.props.amount) {
|
||||
header.props.amount = this.props.entries.length;
|
||||
BDFDB.ReactUtils.forceUpdate(header);
|
||||
}
|
||||
});
|
||||
|
||||
if (forceRerenderGenerator && this.props.tab == "Generator") BDFDB.TimeUtils.timeout(_ => {
|
||||
forceRerenderGenerator = false;
|
||||
BDFDB.ReactUtils.forceUpdate(this);
|
||||
});
|
||||
|
||||
return [
|
||||
return BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN._repo,
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCNS._repolistheader + BDFDB.disCN.settingswindowcontentcolumndefault,
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
|
||||
className: BDFDB.disCN.marginbottom4,
|
||||
align: BDFDB.LibraryComponents.Flex.Align.CENTER,
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
||||
grow: 1,
|
||||
shrink: 0,
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormTitle, {
|
||||
tag: BDFDB.LibraryComponents.FormComponents.FormTitle.Tags.H2,
|
||||
className: BDFDB.disCN.marginreset,
|
||||
children: `Theme Repo — ${loading.is ? 0 : this.props.entries.length || 0}/${loading.is ? 0 : grabbedThemes.length}`
|
||||
})
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SearchBar, {
|
||||
autoFocus: true,
|
||||
query: searchString,
|
||||
onChange: value => {
|
||||
if (loading.is) return;
|
||||
BDFDB.TimeUtils.clear(searchTimeout);
|
||||
searchTimeout = BDFDB.TimeUtils.timeout(_ => {
|
||||
searchString = value.replace(/[<|>]/g, "");
|
||||
BDFDB.ReactUtils.forceUpdate(this);
|
||||
}, 1000);
|
||||
},
|
||||
onClear: _ => {
|
||||
if (loading.is) return;
|
||||
searchString = "";
|
||||
BDFDB.ReactUtils.forceUpdate(this);
|
||||
}
|
||||
})
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Button, {
|
||||
size: BDFDB.LibraryComponents.Button.Sizes.TINY,
|
||||
children: BDFDB.LanguageUtils.LibraryStrings.check_for_updates,
|
||||
onClick: _ => {
|
||||
if (loading.is) return;
|
||||
loading = {is: false, timeout: null, amount: 0};
|
||||
_this.loadThemes();
|
||||
}
|
||||
})
|
||||
]
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
|
||||
className: BDFDB.disCNS.tabbarcontainer + BDFDB.disCN.tabbarcontainerbottom,
|
||||
align: BDFDB.LibraryComponents.Flex.Align.CENTER,
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TabBar, {
|
||||
className: BDFDB.disCN.tabbar,
|
||||
itemClassName: BDFDB.disCN.tabbaritem,
|
||||
type: BDFDB.LibraryComponents.TabBar.Types.TOP,
|
||||
selectedItem: this.props.tab,
|
||||
items: [{value: "Themes"}, {value: "Generator"}, {value: BDFDB.LanguageUtils.LanguageStrings.SETTINGS}],
|
||||
onItemSelect: value => {
|
||||
this.props.tab = value;
|
||||
BDFDB.ReactUtils.forceUpdate(this);
|
||||
}
|
||||
})
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.QuickSelect, {
|
||||
label: BDFDB.LanguageUtils.LibraryStrings.sort_by + ":",
|
||||
value: {
|
||||
label: sortKeys[this.props.sortKey],
|
||||
value: this.props.sortKey
|
||||
},
|
||||
options: Object.keys(sortKeys).map(key => ({
|
||||
label: sortKeys[key],
|
||||
value: key
|
||||
})),
|
||||
onChange: key => {
|
||||
this.props.sortKey = key;
|
||||
BDFDB.ReactUtils.forceUpdate(this);
|
||||
}
|
||||
})
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.QuickSelect, {
|
||||
label: BDFDB.LanguageUtils.LibraryStrings.order + ":",
|
||||
value: {
|
||||
label: BDFDB.LanguageUtils.LibraryStrings[orderKeys[this.props.orderKey]],
|
||||
value: this.props.orderKey
|
||||
},
|
||||
options: Object.keys(orderKeys).map(key => ({
|
||||
label: BDFDB.LanguageUtils.LibraryStrings[orderKeys[key]],
|
||||
value: key
|
||||
})),
|
||||
onChange: key => {
|
||||
this.props.orderKey = key;
|
||||
BDFDB.ReactUtils.forceUpdate(this);
|
||||
}
|
||||
})
|
||||
})
|
||||
]
|
||||
})
|
||||
]
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Scrollers.Auto, {
|
||||
className: BDFDB.disCNS._repolistscroller + BDFDB.disCN.settingswindowcontentcolumndefault,
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ModalComponents.ModalTabContent, {
|
||||
tab: "Themes",
|
||||
open: this.props.tab == "Themes",
|
||||
|
@ -368,7 +467,10 @@ module.exports = (_ => {
|
|||
}))
|
||||
].flat(10).filter(n => n)
|
||||
})
|
||||
];
|
||||
]
|
||||
})
|
||||
]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -656,116 +758,6 @@ module.exports = (_ => {
|
|||
}
|
||||
};
|
||||
|
||||
const RepoListHeaderComponent = class ThemeListHeader extends BdApi.React.Component {
|
||||
componentDidMount() {
|
||||
header = this;
|
||||
}
|
||||
render() {
|
||||
if (!this.props.tab) this.props.tab = "Themes";
|
||||
return BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN._repolistheader,
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
|
||||
className: BDFDB.disCN.marginbottom4,
|
||||
align: BDFDB.LibraryComponents.Flex.Align.CENTER,
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
||||
grow: 1,
|
||||
shrink: 0,
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormTitle, {
|
||||
tag: BDFDB.LibraryComponents.FormComponents.FormTitle.Tags.H2,
|
||||
className: BDFDB.disCN.marginreset,
|
||||
children: `Theme Repo — ${loading.is ? 0 : this.props.amount || 0}/${loading.is ? 0 : grabbedThemes.length}`
|
||||
})
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SearchBar, {
|
||||
autoFocus: true,
|
||||
query: searchString,
|
||||
onChange: (value, instance) => {
|
||||
if (loading.is) return;
|
||||
BDFDB.TimeUtils.clear(searchTimeout);
|
||||
searchTimeout = BDFDB.TimeUtils.timeout(_ => {
|
||||
searchString = value.replace(/[<|>]/g, "");
|
||||
BDFDB.ReactUtils.forceUpdate(this, list);
|
||||
}, 1000);
|
||||
},
|
||||
onClear: instance => {
|
||||
if (loading.is) return;
|
||||
searchString = "";
|
||||
BDFDB.ReactUtils.forceUpdate(this, list);
|
||||
}
|
||||
})
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Button, {
|
||||
size: BDFDB.LibraryComponents.Button.Sizes.TINY,
|
||||
children: BDFDB.LanguageUtils.LibraryStrings.check_for_updates,
|
||||
onClick: _ => {
|
||||
if (loading.is) return;
|
||||
loading = {is: false, timeout: null, amount: 0};
|
||||
_this.loadThemes();
|
||||
}
|
||||
})
|
||||
]
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
|
||||
className: BDFDB.disCNS.tabbarcontainer + BDFDB.disCN.tabbarcontainerbottom,
|
||||
align: BDFDB.LibraryComponents.Flex.Align.CENTER,
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TabBar, {
|
||||
className: BDFDB.disCN.tabbar,
|
||||
itemClassName: BDFDB.disCN.tabbaritem,
|
||||
type: BDFDB.LibraryComponents.TabBar.Types.TOP,
|
||||
selectedItem: this.props.tab,
|
||||
items: [{value: "Themes"}, {value: "Generator"}, {value: BDFDB.LanguageUtils.LanguageStrings.SETTINGS}],
|
||||
onItemSelect: value => {
|
||||
this.props.tab = list.props.tab = value;
|
||||
BDFDB.ReactUtils.forceUpdate(list);
|
||||
}
|
||||
})
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.QuickSelect, {
|
||||
label: BDFDB.LanguageUtils.LibraryStrings.sort_by + ":",
|
||||
value: {
|
||||
label: sortKeys[this.props.sortKey],
|
||||
value: this.props.sortKey
|
||||
},
|
||||
options: Object.keys(sortKeys).map(key => ({
|
||||
label: sortKeys[key],
|
||||
value: key
|
||||
})),
|
||||
onChange: key => {
|
||||
this.props.sortKey = list.props.sortKey = key;
|
||||
BDFDB.ReactUtils.forceUpdate(this, list);
|
||||
}
|
||||
})
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.QuickSelect, {
|
||||
label: BDFDB.LanguageUtils.LibraryStrings.order + ":",
|
||||
value: {
|
||||
label: BDFDB.LanguageUtils.LibraryStrings[orderKeys[this.props.orderKey]],
|
||||
value: this.props.orderKey
|
||||
},
|
||||
options: Object.keys(orderKeys).map(key => ({
|
||||
label: BDFDB.LanguageUtils.LibraryStrings[orderKeys[key]],
|
||||
value: key
|
||||
})),
|
||||
onChange: key => {
|
||||
this.props.orderKey = list.props.orderKey = key;
|
||||
BDFDB.ReactUtils.forceUpdate(this, list);
|
||||
}
|
||||
})
|
||||
})
|
||||
]
|
||||
})
|
||||
]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return class ThemeRepo extends Plugin {
|
||||
onLoad () {
|
||||
_this = this;
|
||||
|
@ -791,13 +783,14 @@ module.exports = (_ => {
|
|||
}
|
||||
};
|
||||
|
||||
this.patchedModules = {
|
||||
before: {
|
||||
SettingsView: ["render", "componentWillUnmount"]
|
||||
},
|
||||
after: {
|
||||
StandardSidebarView: "default"
|
||||
}
|
||||
this.modulePatches = {
|
||||
before: [
|
||||
"SettingsView",
|
||||
"StandardSidebarView"
|
||||
],
|
||||
componentWillUnmount: [
|
||||
"SettingsView"
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -847,8 +840,8 @@ module.exports = (_ => {
|
|||
|
||||
processSettingsView (e) {
|
||||
if (e.node) searchString = "";
|
||||
else {
|
||||
if (!BDFDB.PatchUtils.isPatched(this, e.component, "getPredicateSections")) BDFDB.PatchUtils.patch(this, e.component, "getPredicateSections", {after: e2 => {
|
||||
else if (e.component.prototype && !BDFDB.PatchUtils.isPatched(this, e.component.prototype, "getPredicateSections")) {
|
||||
BDFDB.PatchUtils.patch(this, e.component.prototype, "getPredicateSections", {after: e2 => {
|
||||
if (BDFDB.ArrayUtils.is(e2.returnValue) && e2.returnValue.findIndex(n => n.section && (n.section.toLowerCase() == "changelog" || n.section == BDFDB.DiscordConstants.UserSettingsSections.CHANGE_LOG || n.section.toLowerCase() == "logout" || n.section == BDFDB.DiscordConstants.UserSettingsSections.LOGOUT))) {
|
||||
e2.returnValue = e2.returnValue.filter(n => n.section != "themerepo");
|
||||
let index = e2.returnValue.indexOf(e2.returnValue.find(n => n.section == "pluginrepo") || e2.returnValue.find(n => n.section == "themes") || e2.returnValue.find(n => n.section == BDFDB.DiscordConstants.UserSettingsSections.DEVELOPER_OPTIONS) || e2.returnValue.find(n => n.section == BDFDB.DiscordConstants.UserSettingsSections.HYPESQUAD_ONLINE));
|
||||
|
@ -879,20 +872,7 @@ module.exports = (_ => {
|
|||
}
|
||||
|
||||
processStandardSidebarView (e) {
|
||||
if (e.instance.props.section == "themerepo") {
|
||||
let content = BDFDB.ReactUtils.findChild(e.returnvalue, {props: [["className", BDFDB.disCN.settingswindowcontentregion]]});
|
||||
if (content) content.props.className = BDFDB.DOMUtils.formatClassName(BDFDB.disCN._repolistwrapper, content.props.className);
|
||||
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {props: [["className", BDFDB.disCN.settingswindowcontentregionscroller]]});
|
||||
if (index > -1) {
|
||||
let options = {};
|
||||
options.sortKey = forcedSort || Object.keys(sortKeys)[0];
|
||||
options.orderKey = forcedOrder || Object.keys(orderKeys)[0];
|
||||
children[index] = [
|
||||
BDFDB.ReactUtils.createElement(RepoListHeaderComponent, options),
|
||||
children[index]
|
||||
];
|
||||
}
|
||||
}
|
||||
if (e.instance.props.section == "themerepo") e.instance.props.contentType = "custom";
|
||||
}
|
||||
|
||||
generateTheme (fullCSS, generatorValues) {
|
||||
|
@ -1062,7 +1042,7 @@ module.exports = (_ => {
|
|||
});
|
||||
BDFDB.PluginUtils.addLoadingIcon(loadingIcon);
|
||||
|
||||
BDFDB.ReactUtils.forceUpdate(list, header);
|
||||
BDFDB.ReactUtils.forceUpdate(list);
|
||||
|
||||
for (let i = 0; i <= 20; i++) checkTheme();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue