Skip to content

Commit

Permalink
Fix Image Backgrounds crashing media views (#20)
Browse files Browse the repository at this point in the history
- Removed comments from the BG hook as I decided I'm not going to do this
- Ensures that the length of subviews is at least 3 so that it does not into the negatives (2-3=-1 and so on). This would cause a native crash when trying to open a Media/Image view because the amount of subviews there is less than 3, meaning that when the Image bg subview is inserted it tries to insert it into a negative index.
  • Loading branch information
acquitelol authored Apr 14, 2023
1 parent 642da81 commit 28df3be
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 13 deletions.
2 changes: 1 addition & 1 deletion control
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: app.enmity
Name: Enmity
Version: 2.2.3
Version: 2.2.4
Architecture: iphoneos-arm
Description: The power of addons, all in your hand.
Maintainer: Rosie
Expand Down
2 changes: 1 addition & 1 deletion src/Enmity.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#define ENMITY_PATH [NSString stringWithFormat:@"%@/%@", NSHomeDirectory(), @"Documents/Enmity.js"]
#define ENMITY_SOURCE [NSURL URLWithString:@"enmity"]
#define VERSION @"2.2.3"
#define VERSION @"2.2.4"
#define TYPE @"Regular"

// Disable logs in release mode
Expand Down
12 changes: 1 addition & 11 deletions src/Theme.xi
Original file line number Diff line number Diff line change
Expand Up @@ -478,17 +478,7 @@ HOOK_TABLE_CELL(DCDLoadingTableViewCell)

NSString *url = getBackgroundURL();

// ! THIS PATCH IS TEMPORARY !
// for the time being this is done in the native side because it is extremely buggy on the js side
// for documentation purposes, the following issues are occuring with the current way that i am doing it on the js side (patch the common component that loads a linear gradient behind the chat area)
// 1. background is not transparent when using regular dark/light and not client themes
// 2. background does not apply on tabsv2
// 3. chat area is not interactive at all (unscrollable and chatinput is dead)
// 4. toggling between chat area and member view triggers fast flashing of the image
// 5. image is not positioned properly some of the time
//
// once i figure out how to properly do this on the js side (preferrably not patching View.render too) i will remove this implementation and do the proper js implementation.
UIView *subview = self.subviews[[self.subviews count] - 3];
UIView *subview = self.subviews[[self.subviews count] >= 3 ? [self.subviews count] - 3 : 0];

if (subview && [subview isKindOfClass:[UIImageView class]]) {
return NSLog(@"Image is a UIImageView!: %@", (id)[NSNumber numberWithBool:[subview isKindOfClass:[UIImageView class]] ]);
Expand Down

0 comments on commit 28df3be

Please sign in to comment.