stuff
This commit is contained in:
parent
835d7d46a7
commit
c47eb8ca94
|
@ -399,6 +399,7 @@
|
||||||
"SearchResult": {"strings": [".onJump", "message:", "handleMessageClick"]},
|
"SearchResult": {"strings": [".onJump", "message:", "handleMessageClick"]},
|
||||||
"SearchResults": {"strings": ["SEARCH_ERROR", "emptyResultsText", "isSearching"]},
|
"SearchResults": {"strings": ["SEARCH_ERROR", "emptyResultsText", "isSearching"]},
|
||||||
"SearchResultsInner": {"strings": ["SEARCH_HIDE_BLOCKED_MESSAGES", "totalResults", "\"search-result-\""]},
|
"SearchResultsInner": {"strings": ["SEARCH_HIDE_BLOCKED_MESSAGES", "totalResults", "\"search-result-\""]},
|
||||||
|
"SearchResultsPagination": {"strings": [".pageLength", ".changePage", "maxVisiblePages"]},
|
||||||
"SettingsView": {"strings": ["tabBarItemContainer", "PROFILE_CUSTOMIZATION", "badgeCount"]},
|
"SettingsView": {"strings": ["tabBarItemContainer", "PROFILE_CUSTOMIZATION", "badgeCount"]},
|
||||||
"Shakeable": {"protos": ["shake", "getDefaultAnimProps", "stop"]},
|
"Shakeable": {"protos": ["shake", "getDefaultAnimProps", "stop"]},
|
||||||
"Spoiler": {"strings": ["revealSpoiler", ".onReveal"]},
|
"Spoiler": {"strings": ["revealSpoiler", ".onReveal"]},
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* @name BetterSearchPage
|
* @name BetterSearchPage
|
||||||
* @author DevilBro
|
* @author DevilBro
|
||||||
* @authorId 278543574059057154
|
* @authorId 278543574059057154
|
||||||
* @version 1.2.0
|
* @version 1.2.1
|
||||||
* @description Adds some extra Controls to the Search Results Page
|
* @description Adds some extra Controls to the Search Results Page
|
||||||
* @invite Jx3TjNS
|
* @invite Jx3TjNS
|
||||||
* @donate https://www.paypal.me/MircoWittrien
|
* @donate https://www.paypal.me/MircoWittrien
|
||||||
|
@ -56,21 +56,19 @@ module.exports = (_ => {
|
||||||
return template.content.firstElementChild;
|
return template.content.firstElementChild;
|
||||||
}
|
}
|
||||||
} : (([Plugin, BDFDB]) => {
|
} : (([Plugin, BDFDB]) => {
|
||||||
var settings = {};
|
|
||||||
|
|
||||||
return class BetterSearchPage extends Plugin {
|
return class BetterSearchPage extends Plugin {
|
||||||
onLoad () {
|
onLoad () {
|
||||||
this.defaults = {
|
this.defaults = {
|
||||||
settings: {
|
general: {
|
||||||
addJumpTo: {value: true, description: "Add a Jump to Input Field (press enter to Jump)"},
|
addJumpTo: {value: true, description: "Add a Jump to Input Field (press enter to Jump)"},
|
||||||
cloneToTheTop: {value: true, description: "Clone the controls to the top of the Results Page"}
|
cloneToTheTop: {value: true, description: "Clone the controls to the top of the Results Page"}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.patchedModules = {
|
this.modulePatches = {
|
||||||
after: {
|
after: [
|
||||||
SearchResultsInner: "default"
|
"SearchResultsInner"
|
||||||
}
|
]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,12 +83,12 @@ module.exports = (_ => {
|
||||||
getSettingsPanel (collapseStates = {}) {
|
getSettingsPanel (collapseStates = {}) {
|
||||||
let settingsPanel, settingsItems = [];
|
let settingsPanel, settingsItems = [];
|
||||||
|
|
||||||
for (let key in settings) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
for (let key in general) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||||
type: "Switch",
|
type: "Switch",
|
||||||
plugin: this,
|
plugin: this,
|
||||||
keys: ["settings", key],
|
keys: ["general", key],
|
||||||
label: this.defaults.settings[key].description,
|
label: this.defaults.general[key].description,
|
||||||
value: settings[key]
|
value: this.settings.general[key]
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
|
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
|
||||||
|
@ -104,15 +102,14 @@ module.exports = (_ => {
|
||||||
}
|
}
|
||||||
|
|
||||||
forceUpdateAll () {
|
forceUpdateAll () {
|
||||||
settings = BDFDB.DataUtils.get(this, "settings");
|
|
||||||
|
|
||||||
BDFDB.PatchUtils.forceAllUpdates(this);
|
BDFDB.PatchUtils.forceAllUpdates(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
processSearchResultsInner (e) {
|
processSearchResultsInner (e) {
|
||||||
if (e.instance.props.search) {
|
if (!e.instance.props.search) return;
|
||||||
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "SearchPagination"});
|
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "SearchResultsPagination"});
|
||||||
if (index > -1) {
|
console.log(children, index);
|
||||||
|
if (index == -1) return;
|
||||||
let currentPage = parseInt(Math.floor(e.instance.props.search.offset / BDFDB.DiscordConstants.SEARCH_PAGE_SIZE)) + 1;
|
let currentPage = parseInt(Math.floor(e.instance.props.search.offset / BDFDB.DiscordConstants.SEARCH_PAGE_SIZE)) + 1;
|
||||||
let maxPage = e.instance.props.search.totalResults > 5000 ? parseInt(Math.ceil(5000 / BDFDB.DiscordConstants.SEARCH_PAGE_SIZE)) : parseInt(Math.ceil(e.instance.props.search.totalResults / BDFDB.DiscordConstants.SEARCH_PAGE_SIZE));
|
let maxPage = e.instance.props.search.totalResults > 5000 ? parseInt(Math.ceil(5000 / BDFDB.DiscordConstants.SEARCH_PAGE_SIZE)) : parseInt(Math.ceil(e.instance.props.search.totalResults / BDFDB.DiscordConstants.SEARCH_PAGE_SIZE));
|
||||||
|
|
||||||
|
@ -120,9 +117,9 @@ module.exports = (_ => {
|
||||||
|
|
||||||
let pagination = children[index].type(children[index].props);
|
let pagination = children[index].type(children[index].props);
|
||||||
if (!pagination || maxPage < 2) return;
|
if (!pagination || maxPage < 2) return;
|
||||||
pagination.props.className = BDFDB.DOMUtils.formatClassName(pagination.props.className, BDFDB.disCN.pagination, BDFDB.disCN._bettersearchpagepagination, settings.addJumpTo && BDFDB.disCN.paginationmini);
|
pagination.props.className = BDFDB.DOMUtils.formatClassName(pagination.props.className, BDFDB.disCN.pagination, BDFDB.disCN._bettersearchpagepagination, this.settings.general.addJumpTo && BDFDB.disCN.paginationmini);
|
||||||
|
|
||||||
if (settings.addJumpTo) {
|
if (this.settings.general.addJumpTo) {
|
||||||
pagination.props.children = [
|
pagination.props.children = [
|
||||||
pagination.props.children,
|
pagination.props.children,
|
||||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
|
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
|
||||||
|
@ -142,15 +139,13 @@ module.exports = (_ => {
|
||||||
].flat(10).filter(n => n);
|
].flat(10).filter(n => n);
|
||||||
}
|
}
|
||||||
children[index] = pagination;
|
children[index] = pagination;
|
||||||
if (settings.cloneToTheTop) {
|
if (this.settings.general.cloneToTheTop) {
|
||||||
let topPagination = BDFDB.ReactUtils.cloneElement(pagination);
|
let topPagination = BDFDB.ReactUtils.cloneElement(pagination);
|
||||||
topPagination.props.className = BDFDB.DOMUtils.formatClassName(topPagination.props.className, BDFDB.disCN.paginationtop);
|
topPagination.props.className = BDFDB.DOMUtils.formatClassName(topPagination.props.className, BDFDB.disCN.paginationtop);
|
||||||
children.unshift(topPagination);
|
children.unshift(topPagination);
|
||||||
}
|
}
|
||||||
pagination.props.className = BDFDB.DOMUtils.formatClassName(pagination.props.className, BDFDB.disCN.paginationbottom);
|
pagination.props.className = BDFDB.DOMUtils.formatClassName(pagination.props.className, BDFDB.disCN.paginationbottom);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
})(window.BDFDB_Global.PluginUtils.buildPlugin(changeLog));
|
})(window.BDFDB_Global.PluginUtils.buildPlugin(changeLog));
|
||||||
})();
|
})();
|
Loading…
Reference in New Issue