From 6ea23d94cb55aed8d991b0a26da88827b6db056d Mon Sep 17 00:00:00 2001 From: TrueZhuanjia Date: Sun, 13 Jul 2025 00:09:42 +0800 Subject: [PATCH] minor fixes --- .../ViewControllers/MainFrameViewController.m | 15 ++++++--- .../StreamFrameViewController.m | 31 +++++++++---------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/VoidLink/ViewControllers/MainFrameViewController.m b/VoidLink/ViewControllers/MainFrameViewController.m index 1141d85b..8ad36f8b 100644 --- a/VoidLink/ViewControllers/MainFrameViewController.m +++ b/VoidLink/ViewControllers/MainFrameViewController.m @@ -74,6 +74,7 @@ SettingsViewController* settingsViewController; StreamFrameViewController* streamFrameViewController; id navBarAppearanceStandard; + bool _viewJustAppeared; NSTimer *_foregroundHostUpdateTimer; @@ -1625,9 +1626,13 @@ static NSMutableSet* hostList; -(void)beginForegroundRefresh { - if (!_background) { + if (!_background || _viewJustAppeared) { // This will kick off box art caching + _viewJustAppeared = false; + + [_foregroundHostUpdateTimer invalidate]; + _foregroundHostUpdateTimer = nil; _foregroundHostUpdateTimer = [NSTimer scheduledTimerWithTimeInterval:5 repeats:YES block:^(NSTimer *timer) { [self updateHosts]; @@ -1693,7 +1698,11 @@ static NSMutableSet* hostList; - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:NO]; - + + _viewJustAppeared = true; + + [self beginForegroundRefresh]; + // [self setupHostViewTitle]; // [self reloadScrollHostView]; //remove this for proper test [self attachWaterMark]; @@ -1774,8 +1783,6 @@ static NSMutableSet* hostList; [self retrieveSavedHosts]; _discMan = [[DiscoveryManager alloc] initWithHosts:[hostList allObjects] andCallback:self]; - - [self beginForegroundRefresh]; } - (void)viewDidDisappear:(BOOL)animated diff --git a/VoidLink/ViewControllers/StreamFrameViewController.m b/VoidLink/ViewControllers/StreamFrameViewController.m index e510d9e4..e7020349 100644 --- a/VoidLink/ViewControllers/StreamFrameViewController.m +++ b/VoidLink/ViewControllers/StreamFrameViewController.m @@ -859,26 +859,13 @@ //[self.pipController startPictureInPicture]; //sleep(1); - if (_inactivityTimer != nil) { - [_inactivityTimer invalidate]; - _inactivityTimer = nil; - } - - #if !TARGET_OS_TV - // Terminate the stream if the app is inactive for 60 seconds - Log(LOG_I, @"Starting inactivity termination timer with %d min", _settings.backgroundSessionTimer.intValue); - _inactivityTimer = [NSTimer scheduledTimerWithTimeInterval:60*(double)_settings.backgroundSessionTimer.intValue - target:self - selector:@selector(inactiveTimerExpired:) - userInfo:nil - repeats:NO]; #endif } - (void)inactiveTimerExpired:(NSTimer*)timer { Log(LOG_I, @"Terminating stream after inactivity"); - + [self returnToMainFrame]; _inactivityTimer = nil; @@ -901,9 +888,21 @@ NSLog(@"did enter background, %d, %@, %d", _settings.enablePIP, self.pipController, self.pipController.isPictureInPictureActive); if (_settings.enablePIP && self.pipController && self.pipController.isPictureInPictureActive) { - Log(LOG_I, @"PIP is active, not terminating stream"); - return; + //Log(LOG_I, @"PIP is active, not terminating stream"); } + + if (_inactivityTimer != nil) { + [_inactivityTimer invalidate]; + _inactivityTimer = nil; + } + + // Terminate the stream if the app is inactive for ... + Log(LOG_I, @"Starting inactivity termination timer with %d min", _settings.backgroundSessionTimer.intValue); + _inactivityTimer = [NSTimer scheduledTimerWithTimeInterval:60*(double)_settings.backgroundSessionTimer.intValue + target:self + selector:@selector(inactiveTimerExpired:) + userInfo:nil + repeats:NO]; #if !TARGET_OS_TV