@@ -17,21 +17,28 @@ - (void)closeSidebarWithAnimation:(BOOL)arg1 completionHandler:(CDUnknownBlockTy
1717@end
1818
1919ZKSwizzleInterface ($_Replacement, PVWindowController, NSObject );
20-
2120@implementation $_Replacement
21+ // we need this here so we can call it
22+ // would use performSelector:withObject:withObject but BOOL isnt an object
23+ // alternative would be NSInvocation
2224- (void )closeSidebarWithAnimation:(BOOL )arg1 completionHandler:(CDUnknownBlockType)arg2
2325{
2426 ZKOrig (void , arg2, arg2);
2527}
2628
27-
29+ // openSidebarWithAnimation is called from windowDidLoad
30+ // I just undo what it did already, closing the sidebar if there is only one page open in
31+ // the window and it is a PDF
2832- (void )windowDidLoad
2933{
3034 ZKOrig (void );
31- NSArray *array = [ZKHookIvar (self , NSArrayController *, " _containersArrayController" ) arrangedObjects ];
32- if ( [array count ] == 1
33- && [[array firstObject ] class ] == NSClassFromString (@" PVPDFPageContainer" )) {
34- [self closeSidebarWithAnimation: NO completionHandler: nil ];
35+ id arrayIvar = ZKHookIvar (self, id , " _containersArrayController" );
36+ if ([arrayIvar class ] == NSClassFromString (@" NSArrayController" )) {;
37+ NSArray *array = [(NSArrayController *)arrayIvar arrangedObjects ];
38+ if ([array count ] == 1 &&
39+ [[array firstObject ] class ] == NSClassFromString (@" PVPDFPageContainer" )) {
40+ [self closeSidebarWithAnimation: NO completionHandler: nil ];
41+ }
3542 }
3643}
3744
0 commit comments