-
Notifications
You must be signed in to change notification settings - Fork 24.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
prevent from publishing dimensions change event when app changes state #34014
Changes from 3 commits
8653851
b0c3bc7
e21080d
b4b38d2
818a073
27e65a5
f690dc1
0bee080
e5856b0
320cb11
9d2be30
cabdc03
394fd10
23f6564
ff62965
575f054
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -174,12 +174,15 @@ - (void)interfaceOrientationDidChange | |
|
||
- (void)_interfaceOrientationDidChange | ||
{ | ||
UIInterfaceOrientation nextOrientation = [RCTSharedApplication() statusBarOrientation]; | ||
UIApplicationState appState = [RCTSharedApplication() applicationState]; | ||
BOOL isRunningInFullScreen = CGRectEqualToRect([UIApplication sharedApplication].delegate.window.frame, [UIApplication sharedApplication].delegate.window.screen.bounds); | ||
|
||
UIApplication *application = RCTSharedApplication(); | ||
if(!application) { | ||
return; | ||
} | ||
UIInterfaceOrientation nextOrientation = [application statusBarOrientation]; | ||
|
||
BOOL isActive = appState == UIApplicationStateActive; | ||
BOOL isRunningInFullScreen = CGRectEqualToRect(application.delegate.window.frame, application.delegate.window.screen.bounds); | ||
lbaldy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
BOOL isActive = RCTIsAppActive(); | ||
// We are catching here two situations for multitasking view: | ||
// a) The app is in Split View and the container gets resized -> !isRunningInFullScreen | ||
// b) The app changes to/from fullscreen example: App runs in slide over mode and goes into fullscreen-> isRunningInFullScreen != _isFullscreen | ||
|
@@ -192,15 +195,15 @@ - (void)_interfaceOrientationDidChange | |
// Update when we go from portrait to landscape, or landscape to portrait | ||
// Also update when the fullscreen state changes (multitasking) and only when the app is in active state. | ||
if ((isOrientationChanging || isResizingOrChangingToFullscreen) && isActive) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. isActive is used only once, here. You can use the |
||
#pragma clang diagnostic push | ||
#pragma clang diagnostic ignored "-Wdeprecated-declarations" | ||
#pragma clang diagnostic push | ||
#pragma clang diagnostic ignored "-Wdeprecated-declarations" | ||
[[_moduleRegistry moduleForName:"EventDispatcher"] sendDeviceEventWithName:@"didUpdateDimensions" | ||
body:RCTExportedDimensions(_moduleRegistry, _bridge)]; | ||
// We only want to track the current _currentInterfaceOrientation and _isFullscreen only | ||
// We only want to track the current _currentInterfaceOrientation and _isFullscreen only | ||
// when it happens and only when it is published. | ||
_currentInterfaceOrientation = nextOrientation; | ||
_isFullscreen = isRunningInFullScreen; | ||
#pragma clang diagnostic pop | ||
#pragma clang diagnostic pop | ||
} | ||
|
||
|
||
|
@@ -216,20 +219,23 @@ - (void)interfaceFrameDidChange | |
|
||
- (void)_interfaceFrameDidChange | ||
{ | ||
UIApplication *application = RCTSharedApplication(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could you also remove this variable that is unused? It's make our sanity checks exploding! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
if(!application){ | ||
return; | ||
} | ||
cipolleschi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
NSDictionary *nextInterfaceDimensions = RCTExportedDimensions(_moduleRegistry, _bridge); | ||
UIApplicationState appState = [RCTSharedApplication() applicationState]; | ||
|
||
BOOL isActive = appState == UIApplicationStateActive; | ||
BOOL isActive = RCTIsAppActive(); | ||
// update and publish the even only when the app is in active state | ||
if (!([nextInterfaceDimensions isEqual:_currentInterfaceDimensions]) && isActive) { | ||
#pragma clang diagnostic push | ||
#pragma clang diagnostic ignored "-Wdeprecated-declarations" | ||
#pragma clang diagnostic push | ||
#pragma clang diagnostic ignored "-Wdeprecated-declarations" | ||
[[_moduleRegistry moduleForName:"EventDispatcher"] sendDeviceEventWithName:@"didUpdateDimensions" | ||
body:nextInterfaceDimensions]; | ||
// We only want to track the current _currentInterfaceOrientation only | ||
// We only want to track the current _currentInterfaceOrientation only | ||
// when it happens and only when it is published. | ||
_currentInterfaceDimensions = nextInterfaceDimensions; | ||
#pragma clang diagnostic pop | ||
#pragma clang diagnostic pop | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry to bother, but our linter is asking a new line at the end of the file. Could you please add it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, and pushed