Skip to content

Conversation

sergiou87
Copy link
Member

As an attempt to fix desktop/desktop#14712 this PR encapsulates all usages of the Notifications API inside of GHDesktopNotificationsManager, which is now used only on macOS 10.14 and newer.

I also switched the deployment target to 10.13, in order to get warnings on build time when unavailable APIs are being used.

Comment on lines +23 to +26
// Only macOS 10.14 and newer are supported. Since os.release() gives us the
// Darwin kernel version, it should be a major version of 18 or higher, according
// to https://en.wikipedia.org/wiki/Darwin_%28operating_system%29#Release_history
return majorVersion >= 18
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw on Desktop we use Electron's process.getSystemVersion() instead, but that's not available here. Not sure if there is an alternative to this, but I didn't want to add new dependencies and seems like this check should be reliable enough 🤞

Comment on lines +58 to +66
// Create the desktop notifications manager only if it's a supported macOS version
if (@available(macOS 10.14, *))
{
desktopNotificationsManager = [GHDesktopNotificationsManager new];
}
else
{
return env.Undefined();
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't do a if (!@available(...)) { return } because the compiler is not smart enough to understand everything outside the if is safe for 10.14 🤦

@sergiou87 sergiou87 changed the title Fix support for macOS High Sierra Fix crashes on macOS High Sierra Jun 2, 2022
@sergiou87 sergiou87 mentioned this pull request Jun 2, 2022
Copy link

@tidy-dev tidy-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✨ Makes sense.

(From what I understood from reading fairly foreign syntax to me - but seems there is the check for mac, if good, instantiate a manager. Then, if there is manager, let it handle showing notifications work.)

@sergiou87
Copy link
Member Author

Exactly that, thanks for the quick review! ❤️

@sergiou87 sergiou87 merged commit fc4a598 into main Jun 2, 2022
@sergiou87 sergiou87 deleted the fix-high-sierra-support branch June 2, 2022 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Github Client 3.0.1 Not Opening on macOS High Sierra
2 participants