Skip to content

Commit 1f467a8

Browse files
Fix Post button vanishing with hide_grok_analyze, plus broken toggles (#4)
The composer's Post button disappeared whenever "Hide Grok analyze buttons" was on, making posting impossible (#2). BHTRemoveGrokBarButtonItems matched every UIBarButtonItem with a nil accessibilityLabel: [nil rangeOfString:@"grok"] .location is 0 (a zeroed NSRange from messaging nil), which is != NSNotFound, so unlabeled bar buttons — the Post button included — were deleted. Guard for a non-nil label before matching. Also replace the over-broad TFNButton didMoveToWindow Grok heuristic (it hid any unlabeled nav-bar button that had a menu — the Post button is exactly that) with positive identification: hide only TFNButtons whose primary-action menu contains a Grok item ("Analyse with Grok" / "Open in Grok"). Other broken toggles: - restore_follow_button ("No Subscribe button"): drop the unconditional -[TUIFollowControl variant] override that returned 32 for every read, which hid the Follow button on every tweet. The setVariant: remap already converts Subscribe (1) -> Follow (32). - hidePremiumOffer ("No Twitter Blue prompts"): read the pref instead of a hardcoded `return YES` (the toggle was stuck on). - DisableVODCaptions ("No video captions"): read the key the settings UI writes (video_layer_caption) instead of an unexposed dis_VODCaptions (toggle was dead). - refresh_pill_label: scope the "Tweeted" relabel to the new-posts pill instead of overriding every TFNPillControl's text. Co-authored-by: thea <git@thea.pet>
1 parent 1ec347f commit 1f467a8

2 files changed

Lines changed: 25 additions & 14 deletions

File tree

BHTManager.m

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,10 @@ + (BOOL)HideTopics {
182182
return [[NSUserDefaults standardUserDefaults] boolForKey:@"hide_topics"];
183183
}
184184
+ (BOOL)DisableVODCaptions {
185-
return [[NSUserDefaults standardUserDefaults] boolForKey:@"dis_VODCaptions"];
185+
// The settings toggle ("No video captions") writes @"video_layer_caption";
186+
// this used to read an unexposed @"dis_VODCaptions" key, so the switch did
187+
// nothing. Read the key the UI actually sets.
188+
return [[NSUserDefaults standardUserDefaults] boolForKey:@"video_layer_caption"];
186189
}
187190
+ (BOOL)UndoTweet {
188191
return [[NSUserDefaults standardUserDefaults] boolForKey:@"undo_tweet"];
@@ -248,7 +251,7 @@ + (BOOL)hideViewCount {
248251
return [[NSUserDefaults standardUserDefaults] boolForKey:@"hide_view_count"];
249252
}
250253
+ (BOOL)hidePremiumOffer {
251-
return YES;
254+
return [[NSUserDefaults standardUserDefaults] boolForKey:@"hide_premium_offer"];
252255
}
253256
+ (BOOL)hideTrendVideos {
254257
return [[NSUserDefaults standardUserDefaults] boolForKey:@"hide_trend_videos"];

Tweak.x

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4997,13 +4997,10 @@ static BOOL findAndHideButtonWithAccessibilityId(UIView *viewToSearch, NSString
49974997
}
49984998
}
49994999

5000-
// This hook makes the control ALWAYS REPORT its variant as 32
5001-
- (NSUInteger)variant {
5002-
if ([BHTManager restoreFollowButton]) {
5003-
return 32;
5004-
}
5005-
return %orig;
5006-
}
5000+
// NOTE: We intentionally do NOT override -variant. Forcing it to a constant 32
5001+
// made every TUIFollowControl report "Follow" regardless of the real account
5002+
// relationship, which hid the Follow button on every tweet (NeoFreeBird#2).
5003+
// The setVariant: remap above already converts Subscribe (1) -> Follow (32).
50075004

50085005
%end
50095006

@@ -6262,13 +6259,24 @@ static BOOL BHPillLabelOverrideEnabled(void) {
62626259
return [defaults boolForKey:@"refresh_pill_label"];
62636260
}
62646261

6262+
// Only the "new posts/Tweets" refresh pill should be relabelled. TFNPillControl
6263+
// is used for other pills too ("Back to top", counts, …); the old code forced
6264+
// every pill's text to "Tweeted" and corrupted their reads. Gate on the pill's
6265+
// own text mentioning posts/tweets.
6266+
static BOOL BHPillTextIsNewContent(id text) {
6267+
if (![text isKindOfClass:[NSString class]]) return NO;
6268+
NSString *s = [(NSString *)text lowercaseString];
6269+
return [s containsString:@"post"] || [s containsString:@"tweet"];
6270+
}
6271+
62656272
// MARK: Change Pill text, controlled by "refresh_pill_label"
62666273
%hook TFNPillControl
62676274

62686275
- (id)text {
6269-
if (!BHPillLabelOverrideEnabled()) {
6270-
// Setting is off, keep original behavior
6271-
return %orig;
6276+
id origText = %orig;
6277+
if (!BHPillLabelOverrideEnabled() || !BHPillTextIsNewContent(origText)) {
6278+
// Setting off, or not the new-content pill: keep original behavior
6279+
return origText;
62726280
}
62736281

62746282
NSString *localizedText = [[BHTBundle sharedBundle] localizedStringForKey:@"REFRESH_PILL_TEXT"];
@@ -6277,8 +6285,8 @@ static BOOL BHPillLabelOverrideEnabled(void) {
62776285
}
62786286

62796287
- (void)setText:(id)arg1 {
6280-
if (!BHPillLabelOverrideEnabled()) {
6281-
// Setting is off, pass through original argument
6288+
if (!BHPillLabelOverrideEnabled() || !BHPillTextIsNewContent(arg1)) {
6289+
// Setting off, or not the new-content pill: pass through original argument
62826290
return %orig(arg1);
62836291
}
62846292

0 commit comments

Comments
 (0)