@@ -5,10 +5,21 @@ import { getRenderableScreens, getScreens, getYouData } from "@ui/settings/data"
55
66const layoutModule = findByProps ( "useOverviewSettings" ) ;
77const titleConfigModule = findByProps ( "getSettingTitleConfig" ) ;
8- const gettersModule = findByProps ( "getSettingSearchListItems" ) ;
98const miscModule = findByProps ( "SETTING_RELATIONSHIPS" , "SETTING_RENDERER_CONFIGS" ) ;
109
10+ // Checks for 189.4 and above
11+ // When dropping support for 189.3 and below, following can be done: (unless Discord changes things again)
12+ // const gettersModule = findByProps("getSettingListItems");
13+ const OLD_GETTER_FUNCTION = "getSettingSearchListItems" ;
14+ const NEW_GETTER_FUNCTION = "getSettingListItems" ;
15+ const oldGettersModule = findByProps ( OLD_GETTER_FUNCTION ) ;
16+ const usingNewGettersModule = ! oldGettersModule ;
17+ const getterFunctionName = usingNewGettersModule ? NEW_GETTER_FUNCTION : OLD_GETTER_FUNCTION ;
18+ const gettersModule = oldGettersModule ?? findByProps ( NEW_GETTER_FUNCTION ) ;
19+
1120export default function patchYou ( ) {
21+ if ( ! gettersModule ) return ;
22+
1223 const patches = new Array < Function > ;
1324 const screens = getScreens ( true ) ;
1425 const renderableScreens = getRenderableScreens ( true ) ;
@@ -29,7 +40,7 @@ export default function patchYou() {
2940 ...data . titleConfig ,
3041 } ) ) ) ;
3142
32- patches . push ( after ( "getSettingSearchListItems" , gettersModule , ( [ settings ] , ret ) => [
43+ patches . push ( after ( getterFunctionName , gettersModule , ( [ settings ] , ret ) => [
3344 ...( renderableScreens . filter ( s => settings . includes ( s . key ) ) ) . map ( s => ( {
3445 type : "setting_search_result" ,
3546 ancestorRendererData : data . rendererConfigs [ s . key ] ,
@@ -38,7 +49,8 @@ export default function patchYou() {
3849 breadcrumbs : [ "Vendetta" ] ,
3950 icon : data . rendererConfigs [ s . key ] . icon ,
4051 } ) ) ,
41- ...ret . filter ( ( i : any ) => ! screens . map ( s => s . key ) . includes ( i . setting ) ) ,
52+ // .filter can be removed when dropping support for 189.3 and below (unless Discord changes things again)
53+ ...ret . filter ( ( i : any ) => ( usingNewGettersModule || ! screens . map ( s => s . key ) . includes ( i . setting ) ) )
4254 ] . map ( ( item , index , parent ) => ( { ...item , index, total : parent . length } ) ) ) ) ;
4355
4456 // TODO: We could use a proxy for these
@@ -53,4 +65,4 @@ export default function patchYou() {
5365 miscModule . SETTING_RENDERER_CONFIGS = oldRendererConfigs ;
5466 patches . forEach ( p => p ( ) ) ;
5567 } ;
56- }
68+ }
0 commit comments