This commit is contained in:
thororen1234 2024-06-01 14:32:22 -04:00
parent 268e053d68
commit 7da91d94d8
77 changed files with 3175 additions and 1964 deletions

View file

@ -23,10 +23,10 @@ export default definePlugin({
name: "SearchFix",
description: 'Fixes the annoying "We dropped the magnifying glass!" error.',
settingsAboutComponent: () => <span style={{ color: "white" }}><i><b>This fix isn't perfect, so you may have to reload the search bar to fix issues.</b></i> Discord only allows a max offset of 5000 (this is what causes the magnifying glass error). This means that you can only see precisely 5000 messages into the past, and 5000 messages into the future (when sorting by old). This plugin just jumps to the opposite sorting method to try get around Discord's restriction, but if there is a large search result, and you try to view a message that is unobtainable with both methods of sorting, the plugin will simply show offset 0 (either newest or oldest message depending on the sorting method).</span>,
authors: [EquicordDevs.jaxx],
authors: [EquicordDevs.Jaxx],
patches: [
{
find: '"SearchStore"',
find: ".displayName=\"SearchStore\";",
replacement: {
match: /(\i)\.offset=null!==\((\i)=(\i)\.offset\)&&void 0!==(\i)\?(\i):0/i,
replace: (_, v, v1, query, v3, v4) => `$self.main(${query}), ${v}.offset = null !== (${v1} = ${query}.offset) && void 0 !== ${v3} ? ${v4} : 0`
@ -34,13 +34,14 @@ export default definePlugin({
}
],
main(query) {
if (query.offset <= 5000) return;
query.sort_order = query.sort_order === "asc" ? "desc" : "asc";
if (query.offset > 5000) {
query.sort_order = query.sort_order === "asc" ? "desc" : "asc";
if (query.offset > 5000 - 5000) {
query.offset = 0;
} else {
query.offset -= 5000;
if (query.offset > 5000 - 5000) {
query.offset = 0;
} else {
query.offset -= 5000;
}
}
}
});