Questify: Update patches for sorting, filtering, and the sponsored banner. (#899)
* Updates. * Types I guess.
This commit is contained in:
parent
7c2d0b2aec
commit
9d98775dc1
1 changed files with 24 additions and 18 deletions
|
|
@ -1126,12 +1126,24 @@ function getLastFilterChoices(): { group: string; filter: string; }[] | null {
|
|||
}
|
||||
|
||||
function setLastSortChoice(sort: string): void {
|
||||
if (!sort) sort = "questify";
|
||||
settings.store.lastQuestPageSort = sort;
|
||||
}
|
||||
|
||||
function setLastFilterChoices(filters: { group: string; filter: string; }[]): void {
|
||||
if (!filters || !Object.keys(filters).length || !Object.values(filters).every(f => f.group && f.filter)) { return; }
|
||||
settings.store.lastQuestPageFilters = JSON.parse(JSON.stringify(filters)).reduce((acc, item) => ({ ...acc, [item.filter]: item }), {});
|
||||
function setLastFilterChoices(filters: { group: string; filter: string; }[] | null): void {
|
||||
if (!filters || filters.length === 0) {
|
||||
settings.store.lastQuestPageFilters = {};
|
||||
return;
|
||||
}
|
||||
|
||||
if (!filters.every(f => f && f.group && f.filter)) {
|
||||
return;
|
||||
}
|
||||
|
||||
settings.store.lastQuestPageFilters = (JSON.parse(JSON.stringify(filters)) as { group: string; filter: string; }[]).reduce((acc, item) => {
|
||||
acc[item.filter] = item;
|
||||
return acc;
|
||||
}, {});
|
||||
}
|
||||
|
||||
function getQuestAcceptedButtonProps(quest: Quest, text: string, disabled: boolean, onClick?: () => void) {
|
||||
|
|
@ -1247,8 +1259,8 @@ export default definePlugin({
|
|||
replace: "const shouldHideSponsoredQuestBanner=$self.shouldHideSponsoredQuestBanner();"
|
||||
},
|
||||
{
|
||||
match: /(?<=if\(null!=\i\))return(.{0,60}?}\))/,
|
||||
replace: "if(!shouldHideSponsoredQuestBanner)return $1"
|
||||
match: /(?<=return null;if\(\i)(\).{0,30}?null!=\i)/,
|
||||
replace: "&&!shouldHideSponsoredQuestBanner$1&&!shouldHideSponsoredQuestBanner"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
@ -1533,24 +1545,18 @@ export default definePlugin({
|
|||
replace: "$self.getLastSortChoice()??$1"
|
||||
},
|
||||
{
|
||||
// Set the initial filters.
|
||||
match: /(get\(\i\)\)\?\?)(\i)/,
|
||||
replace: "$1$self.getLastFilterChoices()??$2"
|
||||
},
|
||||
{
|
||||
// Update the last used sort method when it changes.
|
||||
match: /(onChange:)(\i)(.{0,40}?selectedSortMethod)/,
|
||||
replace: "$1(value)=>{$self.settings.store.lastQuestPageSort=value;$2(value);}$3"
|
||||
},
|
||||
{
|
||||
// Update the last used filter choices when they change.
|
||||
match: /(onChange:)(\i)(.{0,40}?selectedFilters)/,
|
||||
replace: "$1(value)=>{$self.settings.store.lastQuestPageFilters=value.reduce((acc,item)=>({...acc,[item.filter]:item}),{});$2(value);}$3"
|
||||
// Set the initial filters and update the filters and sort method when they change.
|
||||
match: /(get\(\i\)\)\?\?)(\i,\[\i\]\),\i=\i.useCallback\((\i)=>{)(.{0,60}?useCallback\((\i)=>{)/,
|
||||
replace: "$1$self.getLastFilterChoices()??$2$self.setLastSortChoice($3);$4$self.setLastFilterChoices($5);"
|
||||
},
|
||||
{
|
||||
// Update the last used sort and filter choices when the toggle setting for either is changed.
|
||||
match: /(?<=ALL,\i.useMemo\(\(\)=>\()({sortMethod:(\i),filters:(\i))/,
|
||||
replace: "$self.setLastSortChoice($2),$self.setLastFilterChoices($3),$1"
|
||||
},
|
||||
{
|
||||
match: /(?<=resetSortingFiltering:\(\)=>{\i\(\),\i\()\i.\i.SUGGESTED/,
|
||||
replace: '"questify"'
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue