Skip to content

Conversation

low-batt
Copy link
Contributor

The commit in the pull request will:

  • Change SleepPreventer.preventSleep to only display an alert once per
    IINA invocation
  • Change Utility.showAlert to support a suppression button
  • Add a button to the alert to allow the user to permanently suppress
    the alert
  • Change the alert to include the error code returned by macOS

Additional text was added to the alert's message requiring localization.

This fixes how IINA reports a macOS power management failure.
The root cause of the failure is in macOS and must be fixed by Apple.


Description:
This commit includes new text that needs localization.
See the issue for screenshots of the new alert.

The commit in the pull request will:
- Change SleepPreventer.preventSleep to only display an alert once per
  IINA invocation
- Change Utility.showAlert to support a suppression button
- Add a button to the alert to allow the user to permanently suppress
  the alert
- Change the alert to include the error code returned by macOS

Additional text was added to the alert's message requiring localization.

This fixes how IINA reports a macOS power management failure.
The root cause of the failure is in macOS and must be fixed by Apple.
static private var preventedSleep = false

/// Ask macOS to not dim or sleep the display.
Copy link
Member

Choose a reason for hiding this comment

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

A brief description is fine but I'd strongly recommend just linking to the issues themselves rather than copying their contents here, because they'll remain up-to-date and are a better place to put extended discussion

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That came from my bias for keeping information with the code after encountering broken links on work projects. I've changed that portion of the comment to just refer to the two issues.

Copy link
Member

Choose a reason for hiding this comment

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

We are not likely to migrate to JIRA anytime soon :P

@@ -28,11 +64,21 @@ class SleepPreventer: NSObject {
&assertionID)
if success == kIOReturnSuccess {
Copy link
Member

Choose a reason for hiding this comment

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

It might be worth converting this to a guard

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -143,7 +143,7 @@

"alert.fatal_error" = "Fatal error: %@ \nThe application will exit now.";
"alert.mpv_error" = "Internal error %@ (%@) when setting option %@.";
"alert.sleep" = "Cannot prevent display sleep!";
"alert.sleep" = "Cannot prevent display sleep!\nmacOS error 0x%0X8";
Copy link
Member

Choose a reason for hiding this comment

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

I think I'd prefer a "Cannot prevent display sleep! (error code)" format, as this better matches how macOS displays errors

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I first considered doing it like that and changed to this to put emphasis on this being a macOS problem. With it now not adding any words to the string should I be updating more of the lanuages, or just base and EN? The alert now looks like:
issue-3842-review-change

Copy link
Member

Choose a reason for hiding this comment

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

lgtm. I prefer to not pass judgement on where the error is coming from, in general we should just present it as it is.

The commit in the pull request will:
- Change SleepPreventer.preventSleep to only display an alert once per
  IINA invocation
- Change Utility.showAlert to support a suppression button
- Add a button to the alert to allow the user to permanently suppress
  the alert
- Change the alert to include the error code returned by macOS

Additional text was added to the alert's message requiring localization.

This fixes how IINA reports a macOS power management failure.
The root cause of the failure is in macOS and must be fixed by Apple.
The commit in the pull request will:
- Change SleepPreventer.preventSleep to only display an alert once per
  IINA invocation
- Change Utility.showAlert to support a suppression button
- Add a button to the alert to allow the user to permanently suppress
  the alert
- Change the alert to include the error code returned by macOS

Additional text was added to the alert's message requiring localization.

This fixes how IINA reports a macOS power management failure.
The root cause of the failure is in macOS and must be fixed by Apple.
@lhc70000 lhc70000 requested a review from uiryuu August 25, 2022 04:09
Copy link
Member

@uiryuu uiryuu left a comment

Choose a reason for hiding this comment

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

Since it's first time we have alert suppression, I think we should also add a "Reset all dialog warnings" function, just like other apps.

Music.app:
image

Xcode:
image

low-batt and others added 2 commits August 26, 2022 15:46
- Change SleepPreventer.preventSleep to only display an alert once per
  IINA invocation
- Change Utility.showAlert to support a suppression button
- Add a button to the alert to allow the user to permanently suppress
  the alert
- Change the alert to include the error code returned by macOS
- Add a button in Preferences/Utilities to restore suppressed alerts

Additional text was added requiring localization.

This fixes how IINA reports a macOS power management failure.
The root cause of the failure is in macOS and must be fixed by Apple.
@uiryuu
Copy link
Member

uiryuu commented Sep 22, 2022

LGTM

@uiryuu uiryuu merged commit f6cc8c4 into iina:develop Sep 24, 2022
@low-batt low-batt linked an issue Oct 18, 2022 that may be closed by this pull request
1 task
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.

🔴 IINA 1.3.0 BUG: Error Cannot prevent display sleep!
3 participants