Skip to content

Commit

Permalink
PR Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin Macharg committed Mar 24, 2020
1 parent eeed34f commit 032e861
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions Source/BugsnagClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -852,20 +852,28 @@ - (void)batteryChanged:(NSNotification *)notif {
- (void)orientationChanged:(NSNotification *)notification {
UIDeviceOrientation currentDeviceOrientation = [UIDevice currentDevice].orientation;
NSString *orientation = BSGOrientationNameFromEnum(currentDeviceOrientation);

// Short-circuit the exit if we don't have enough info to record a full breadcrumb
// or the orientation hasn't changed (false positive).

// No orientation, nothing to be done
if (!orientation) {
return;
}
else if (!_lastOrientation || [orientation isEqualToString:_lastOrientation]) {

// Update the device orientation in metadata
[[self state] addAttribute:BSGKeyOrientation
withValue:orientation
toTabWithName:BSGKeyDeviceState];

// Short-circuit the exit if we don't have enough info to record a full breadcrumb
// or the orientation hasn't changed (false positive).
if (!_lastOrientation || [orientation isEqualToString:_lastOrientation]) {
_lastOrientation = orientation;
return;
}

[self sendBreadcrumbForOrientationChangeNotification:notification withOrientation:orientation];

// Preserve the orientation
// We have an orientation, it's not a dupe and we have a lastOrientation.
// Send a breadcrumb and preserve the orientation.
[self sendBreadcrumbForOrientationChangeNotification:notification
withOrientation:orientation];
_lastOrientation = orientation;
}

Expand Down

0 comments on commit 032e861

Please sign in to comment.