GoogleChromeLabs / web-push-codelab

Other
557 stars 293 forks source link

6. Handle Permission Denied #42

Open kshitijahuja opened 7 years ago

kshitijahuja commented 7 years ago

In the titled part of the codelab, should not the following code line towards the end of the function updateBtn should be removed as it otherwise turns the button ON back?

pushButton.disabled = false;

gauntface commented 7 years ago

Sorry can you provide links to the relevant page on the codelab or the specific section - I don't know what you are referring to.

kshitijahuja commented 7 years ago

Hi Matt,

On this page https://codelabs.developers.google.com/codelabs/push-notifications/index.html?index=..%2F..%2Fpwa-roadshow#5, the function updateBtn has pushButton.disabled set to false. If we set it to false, it interferes with the disabling of the button as it re-enables the disable button on denying the permission, but when we comment it out, and start afresh, the result is that the "enable" button gets disabled.

On Wed, May 3, 2017 at 3:56 AM, Matt Gaunt notifications@github.com wrote:

Sorry can you provide links to the relevant page on the codelab or the specific section - I don't know what you are referring to.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/GoogleChrome/push-notifications/issues/42#issuecomment-298779081, or mute the thread https://github.com/notifications/unsubscribe-auth/ACSXTJvvqrUCQ_GlNfQjtTBELgWFhJtaks5r162RgaJpZM4NOJCm .

gauntface commented 7 years ago

hhmmm can you give me some reproduction steps? The button should be disabled by the notification permission check

function updateBtn() {
  if (Notification.permission === 'denied') {
    pushButton.textContent = 'Push Messaging Blocked.';
    pushButton.disabled = true;
    updateSubscriptionOnServer(null);
    return;
  }

  if (isSubscribed) {
    pushButton.textContent = 'Disable Push Messaging';
  } else {
    pushButton.textContent = 'Enable Push Messaging';
  }

  pushButton.disabled = false;
}