-
Notifications
You must be signed in to change notification settings - Fork 43
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
feat: uncheck the "Send notification" checkbox when a post is published #342
base: main
Are you sure you want to change the base?
Changes from 2 commits
ea4b70d
6309413
76d2a1a
9f63b08
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 |
---|---|---|
|
@@ -32,4 +32,25 @@ window.addEventListener("DOMContentLoaded", () => { | |
setDisplay(customiseWrap, customisePost.checked); | ||
setDisabled(customiseWrapChild, !customisePost.checked); | ||
}); | ||
|
||
// Watch for the Publish button to be added to the DOM | ||
const observer = new MutationObserver((mutations, obs) => { | ||
const publishButton = document.querySelector('.editor-post-publish-button__button'); | ||
|
||
if (publishButton) { | ||
publishButton.addEventListener('click', function() { | ||
setTimeout(() => { | ||
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. A wait is needed here, otherwise the notification won't send. This may because it takes the plugin time to structure the request and immediately unchecking it will mark it as "don't send". Generally I would prefer that functionality not be dependent on waiting. Happy to hear any thoughts or feedback on this. |
||
if (sendPost && sendPost.checked) { | ||
sendPost.click(); | ||
} | ||
}, 1000); | ||
}); | ||
obs.disconnect(); // Stop observing once we've found and handled the button | ||
} | ||
}); | ||
|
||
observer.observe(document.body, { | ||
childList: true, | ||
subtree: true | ||
}); | ||
}); |
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.
The publish button is targeted from the document body (
.editor-post-publish-button__button
) but this might be too brittle since we don't control the class values on that button.We can scrap the entire JS side changes if we'd rather the checkbox just be unchecked once the page is refreshed, which matches the current behavior in v2.