Skip to content

Commit

Permalink
feat: no suggested chats (in dms)
Browse files Browse the repository at this point in the history
  • Loading branch information
SoCuul committed Apr 15, 2024
1 parent 3dea058 commit 8a037fa
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ A feature-rich tweak for Instagram on iOS!\
- Do not save recent searches
- Hide explore posts grid
- Hide trending searches
- No suggested chats (in dms)

### Feed
- Hide ads
Expand Down
1 change: 1 addition & 0 deletions src/Controllers/SettingsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ - (NSArray *)specifiers {
[self newSwitchCellWithTitle:@"Do not save recent searches" detailTitle:@"Search bars will no longer save your recent searches" key:@"no_recent_searches" defaultValue:false changeAction:nil],
[self newSwitchCellWithTitle:@"Hide explore posts grid" detailTitle:@"Hides the grid of suggested posts on the explore/search tab" key:@"hide_explore_grid" defaultValue:false changeAction:nil],
[self newSwitchCellWithTitle:@"Hide trending searches" detailTitle:@"Hides the trending searches under the explore search bar" key:@"hide_trending_searches" defaultValue:true changeAction:nil],
[self newSwitchCellWithTitle:@"No suggested chats" detailTitle:@"Hides the suggested broadcast channels in direct messages" key:@"no_suggested_chats" defaultValue:true changeAction:nil],

// Section 2: Feed
[self newSectionWithTitle:@"Feed" footer:nil],
Expand Down
74 changes: 74 additions & 0 deletions src/Features/General/NoSuggestedChats.x
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#import "../../InstagramHeaders.h"
#import "../../Manager.h"

// Channels dms tab (header)
%hook IGDirectInboxHeaderSectionController
- (id)viewModel {
if ([[%orig title] isEqualToString:@"Suggested"]) {

if ([BHIManager noSuggestedChats]) {
NSLog(@"[BHInsta] Hiding suggested chats");

return nil;
}
else {
return %orig;
}

} else {
return %orig;
}
}
%end

// Channels dms tab (recipients)
%hook IGDirectInboxSuggestedThreadSectionController
- (id)initWithUserSession:(id)arg1 analyticsModule:(id)arg2 delegate:(id)arg3 igvpController:(id)arg4 viewPointActionBlock:(id)arg5 entryPointProvider:(id)arg6 {
if ([BHIManager noSuggestedChats]) {
NSLog(@"[BHInsta] Hiding suggested chats");

return nil;
}
else {
return %orig;
}
}
%end

// Dms search (sponsored section)
%hook IGDirectInboxSearchListAdapterDataSource
- (id)objectsForListAdapter:(id)arg1 {
if ([BHIManager noSuggestedChats]) {

NSMutableArray *newObjs = [%orig mutableCopy];

[newObjs enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(id obj, NSUInteger idx, BOOL *stop) {

// Section header
if ([obj isKindOfClass:%c(IGLabelItemViewModel)]) {
if ([[obj labelTitle] isEqualToString:@"Suggested channels"]) {
NSLog(@"[BHInsta] Hiding suggested chats (header)");

[newObjs removeObjectAtIndex:idx];
}
}

// Broadcast channel recipient
else if ([obj isKindOfClass:%c(IGDirectRecipientCellViewModel)]) {
if ([[obj recipient] isBroadcastChannel]) {
NSLog(@"[BHInsta] Hiding suggested chats (recipients)");

[newObjs removeObjectAtIndex:idx];
}
}

}];

return [newObjs copy];

}
else {
return %orig;
}
}
%end
19 changes: 18 additions & 1 deletion src/InstagramHeaders.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,24 @@
@interface IGInstagramAppDelegate : NSObject <UIApplicationDelegate>
@end

@interface IGLabelItemViewModel : NSObject
- (id)labelTitle;
@end

@interface IGDirectRecipientCellViewModel : NSObject
- (id)recipient;
@end

@interface IGDirectShareRecipient : NSObject
- (BOOL)isBroadcastChannel;
@end



////////////////////////////////////



static BOOL is_iPad() {
if ([(NSString *)[UIDevice currentDevice].model hasPrefix:@"iPad"]) {
return YES;
Expand All @@ -273,7 +291,6 @@ static BOOL is_iPad() {




////////////////////////////////////


Expand Down
1 change: 1 addition & 0 deletions src/Manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
+ (BOOL)noRecentSearches;
+ (BOOL)hideExploreGrid;
+ (BOOL)hideTrendingSearches;
+ (BOOL)noSuggestedChats;
+ (BOOL)Padlock;
+ (BOOL)keepDeletedMessage;
+ (BOOL)hideLastSeen;
Expand Down
3 changes: 3 additions & 0 deletions src/Manager.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ + (BOOL)hideExploreGrid {
+ (BOOL)hideTrendingSearches {
return [[NSUserDefaults standardUserDefaults] boolForKey:@"hide_trending_searches"];
}
+ (BOOL)noSuggestedChats {
return [[NSUserDefaults standardUserDefaults] boolForKey:@"no_suggested_chats"];
}
+ (BOOL)Padlock {
return [[NSUserDefaults standardUserDefaults] boolForKey:@"padlock"];
}
Expand Down
1 change: 1 addition & 0 deletions src/Tweak.x
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ BOOL dmVisualMsgsViewedButtonEnabled = false;
[[NSUserDefaults standardUserDefaults] setBool:true forKey:@"copy_description"];
[[NSUserDefaults standardUserDefaults] setBool:true forKey:@"call_confirm"];
[[NSUserDefaults standardUserDefaults] setBool:true forKey:@"hide_trending_searches"];
[[NSUserDefaults standardUserDefaults] setBool:true forKey:@"no_suggested_chats"];
[[NSUserDefaults standardUserDefaults] setBool:true forKey:@"no_suggested_threads"];

// Display settings modal on screen
Expand Down

0 comments on commit 8a037fa

Please sign in to comment.