Files
RyukGram/src/Features/StoriesAndMessages/InboxRefreshWarning.x
T
faroukbmiled 86eaa95019 [release] RyukGram v1.2.0
### Features
- **Open Instagram links in app (Safari extension)** — bundled Safari web extension (sideload IPA only). Enable in Safari → Extensions; instagram.com links open in the app.
- **Localization** — every user-facing string flows through a central translation layer. Globe button in Settings; missing keys fall back to English. Ships English only — see the "Translating RyukGram" section in the README to add more.
- **Action buttons** — context-aware menus on feed, reels, and stories (expand, repost, download, copy caption, etc.) with per-context default tap action and carousel/multi-story bulk download
- **Enhanced HD downloads** — up to 1080p via DASH + FFmpegKit with quality picker, preview playback, encoding-speed options, and 720p fallback
- **Repost**, **media viewer**, **media zoom** (long-press), **download pill** (frosted glass, stacks concurrent downloads)
- **Fake location** — overrides CoreLocation app-wide, map picker + saved presets, optional quick-toggle button on the Friends Map
- **Messages-only mode** — strips every tab except DM inbox + profile
- **Launch tab** — pick which tab the app opens to
- Full last active date in DMs — show full date instead of "Active 2h ago"
- Custom date format — 12 formats with per-surface toggles (feed, notes/comments/stories, DMs)
- Send files in DMs (experimental)
- View story mentions
- Hide suggested stories
- Story tray long-press actions — view HD profile picture from the tray menu
- Advance on story reply — auto-skip to next story after sending a reply or reaction
- Mark story as seen on reply or emoji reaction
- Hide metrics (likes, comments, shares counts)
- Hide messages tab
- Hide voice/video call buttons in DM thread header (independent toggles)
- Disable app haptics
- Disable reels tab refresh
- Disable disappearing messages mode in DMs
- Follow indicator — shows whether the profile user follows you
- Copy note text on long press
- Zoom profile photo — long press opens full-screen viewer
- Notes actions — copy text, download GIF/audio from notes long-press menu
- Confirm unfollow
- Feed refresh controls — disable background refresh, home button refresh, and home button scroll

### Improvements
- Default tap action: added copy URL, repost, and view mentions options; dynamic menu generation per context
- Settings pages reordered: General → Feed → Stories → Reels → Messages → Profile → Navigation → Saving → Confirmations
- Fake location picker: native Apple Maps-style UI (search, long-press to drop pin, current location)
- Liquid glass floating tab bar + dynamic sizing
- Upload audio: FFmpegKit re-encode + trim for any audio/video input
- Settings reorganized with per-context action button config; new Profile page
- Highlight cover: full-screen viewer replaces direct download
- Switched HD encoder to `h264_videotoolbox` (hardware) — no GPL FFmpegKit required
- Legacy long-press download deprecated (off by default), replaced by action buttons

### Fixes
- Hide suggested stories no longer removes followed users' stories on scroll
- Settings search bar transparency with liquid glass off; auto-deactivates on push
- HD download cancel: tapping pill aborts in-flight downloads + FFmpeg sessions cleanly
- Download pill stuck state on background/foreground, progress reset per download
- Disappearing messages mode confirmation not firing on swipe
- Detailed color picker not working on story draw `†`
- DM seen toggle menu not updating after tap
- Reel refresh confirmation appearing on first app launch `†`
- Reels action button displacing profile pictures on photo reels
- Disappearing DM media download (expand, share, save to Photos with progress pill)
- Carousel "Download all" not showing item count in feed
- Encoding speed setting being ignored for HD downloads
- Various upstream SCInsta merges (Meta AI hiding, suggested chats hiding, notes tray) — marked `†`

> `†` Merged from upstream [SCInsta](https://github.com/SoCuul/SCInsta) by SoCuul

### Credits
- Thanks to [@erupts0](https://github.com/erupts0) (John) for testing and feature suggestions
- Thanks to [@euoradan](https://t.me/euoradan) (Radan) for experimental Instagram feature flag research
- Safari extension forked/cleaned from [BillyCurtis/OpenInstagramSafariExtension](https://github.com/BillyCurtis/OpenInstagramSafariExtension)

### Known Issues
- Preserved unsent messages can't be removed via "Delete for you"; pull-to-refresh clears them (warning available in settings)
- "Delete for you" detection uses a ~2s window after the local action — a real unsend landing in that window may be missed (rare)
2026-04-16 03:03:30 +01:00

135 lines
5.5 KiB
Plaintext

// Pull-to-refresh in the DMs tab silently clears preserved (locally retained)
// unsent messages. This hook intercepts _pullToRefreshIfPossible to show a
// confirmation dialog when both keep_deleted_message and
// warn_refresh_clears_preserved are on.
#import "../../Utils.h"
#import "../../InstagramHeaders.h"
#import <objc/runtime.h>
#import <objc/message.h>
#import <substrate.h>
extern NSMutableSet *sciGetPreservedIds(void);
extern void sciClearPreservedIds(void);
static BOOL sciRefreshConfirmInFlight = NO;
static BOOL sciRefreshAlertVisible = NO;
static UIRefreshControl *sciFindRefreshControl(UIViewController *vc) {
Class igRC = NSClassFromString(@"IGRefreshControl");
NSMutableArray *stack = [NSMutableArray arrayWithObject:vc.view];
while (stack.count > 0) {
UIView *v = stack.lastObject;
[stack removeLastObject];
if ((igRC && [v isKindOfClass:igRC]) || [v isKindOfClass:[UIRefreshControl class]]) {
return (UIRefreshControl *)v;
}
for (UIView *sub in v.subviews) [stack addObject:sub];
}
return nil;
}
// On cancel, the IGRefreshControl's state machine is already idle by the time
// our handler runs — but the scroll view's contentInset stays expanded, leaving
// the spinner area visually exposed. We grab the idle inset via the inbox VC's
// idleTopContentInsetForRefreshControl: helper and animate the inset back.
static void sciCancelRefresh(UIViewController *vc) {
UIRefreshControl *rc = sciFindRefreshControl(vc);
if (!rc) return;
Ivar stateIvar = class_getInstanceVariable([rc class], "_refreshState");
if (stateIvar) {
ptrdiff_t off = ivar_getOffset(stateIvar);
*(NSInteger *)((char *)(__bridge void *)rc + off) = 0;
}
Ivar animIvar = class_getInstanceVariable([rc class], "_swiftAnimationInfo");
if (animIvar) object_setIvar(rc, animIvar, nil);
if ([rc respondsToSelector:@selector(endRefreshing)]) [rc endRefreshing];
SEL didEnd = NSSelectorFromString(@"refreshControlDidEndFinishLoadingAnimation:");
if ([vc respondsToSelector:didEnd]) {
((void(*)(id, SEL, id))objc_msgSend)(vc, didEnd, rc);
}
UIScrollView *scroll = nil;
UIView *cur = rc.superview;
while (cur) {
if ([cur isKindOfClass:[UIScrollView class]]) { scroll = (UIScrollView *)cur; break; }
cur = cur.superview;
}
if (scroll) {
SEL idleSel = NSSelectorFromString(@"idleTopContentInsetForRefreshControl:");
CGFloat idleInset = scroll.contentInset.top;
if ([vc respondsToSelector:idleSel]) {
idleInset = ((CGFloat(*)(id, SEL, id))objc_msgSend)(vc, idleSel, rc);
}
UIEdgeInsets insets = scroll.contentInset;
insets.top = idleInset;
[UIView animateWithDuration:0.25 animations:^{
scroll.contentInset = insets;
CGPoint o = scroll.contentOffset;
if (o.y < -idleInset) o.y = -idleInset;
scroll.contentOffset = o;
}];
}
}
static void (*orig_pullToRefresh)(id self, SEL _cmd);
static void new_pullToRefresh(id self, SEL _cmd) {
if (sciRefreshConfirmInFlight ||
![SCIUtils getBoolPref:@"keep_deleted_message"] ||
![SCIUtils getBoolPref:@"warn_refresh_clears_preserved"]) {
orig_pullToRefresh(self, _cmd);
return;
}
// IG fires _pullToRefreshIfPossible repeatedly while the user holds the
// pull gesture — drop re-entrant calls until the alert is dismissed.
if (sciRefreshAlertVisible) return;
NSUInteger count = sciGetPreservedIds().count;
if (count == 0) {
orig_pullToRefresh(self, _cmd);
return;
}
UIViewController *vc = (UIViewController *)self;
NSString *msg = [NSString stringWithFormat:
@"Refreshing the DMs tab will clear %lu preserved unsent message%@. This cannot be undone.",
(unsigned long)count, count == 1 ? @"" : @"s"];
UIAlertController *alert = [UIAlertController alertControllerWithTitle:SCILocalized(@"Clear preserved messages?")
message:msg
preferredStyle:UIAlertControllerStyleAlert];
__weak UIViewController *weakSelf = vc;
[alert addAction:[UIAlertAction actionWithTitle:SCILocalized(@"Cancel") style:UIAlertActionStyleCancel
handler:^(UIAlertAction *a) {
sciCancelRefresh(weakSelf);
sciRefreshAlertVisible = NO;
}]];
[alert addAction:[UIAlertAction actionWithTitle:SCILocalized(@"Refresh") style:UIAlertActionStyleDestructive
handler:^(UIAlertAction *a) {
sciRefreshAlertVisible = NO;
id strongSelf = weakSelf;
if (!strongSelf) return;
sciClearPreservedIds();
sciRefreshConfirmInFlight = YES;
((void(*)(id, SEL))objc_msgSend)(strongSelf, _cmd);
sciRefreshConfirmInFlight = NO;
}]];
sciRefreshAlertVisible = YES;
UIViewController *top = [UIApplication sharedApplication].keyWindow.rootViewController;
while (top.presentedViewController) top = top.presentedViewController;
[top presentViewController:alert animated:YES completion:nil];
}
%ctor {
Class cls = NSClassFromString(@"IGDirectInboxViewController");
if (!cls) return;
SEL sel = NSSelectorFromString(@"_pullToRefreshIfPossible");
if (class_getInstanceMethod(cls, sel))
MSHookMessageEx(cls, sel, (IMP)new_pullToRefresh, (IMP *)&orig_pullToRefresh);
}