Skip to content
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

Web notifications #49

Merged
merged 15 commits into from
Oct 21, 2020
Merged

Web notifications #49

merged 15 commits into from
Oct 21, 2020

Conversation

dryu99
Copy link
Contributor

@dryu99 dryu99 commented Oct 21, 2020

Screen Shot 2020-10-21 at 1 27 00 AM

  • designed re-usable toggle switch component (@michelleykim 💯)
  • implemented notification toggle container for handling notification settings state (caching included :000)
  • implemented notification popups for new announcements
  • created a utility module to handle Notification api related logic

added some misc comments below for stuff I wasn't sure about 👍

we are welcoming lots lots lots lots lots of feedback ! ! ! !!! !! ! !!!!!!

// firebase doc that triggered db change event
const changedDoc = querySnapshot.docChanges()[0]

// don't want to notify on 'remove' + 'modified' db events
Copy link
Contributor Author

Choose a reason for hiding this comment

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

maybe we want to notify on 'modified' events tho 🤷‍♂️

Copy link
Contributor

Choose a reason for hiding this comment

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

okok I know this is technically out of scope, but thoughts on adding a 'isModified' prop to the Announcement component and add a little edited @ HH:MM:SS message so people know what's been updated

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need to use a notification when events are modified but maybe some other signifier 👍

Comment on lines +4 to +9
export const NOTIFICATION_PERMISSIONS = Object.freeze({
GRANTED: 'granted',
DEFAULT: 'default',
DENIED: 'denied',
})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

was debating whether to put these variables here or in new util module notifications.js, thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

think it should be ok here for now, but if ever need to add more constants then it might be a good idea

jackyzha0
jackyzha0 previously approved these changes Oct 21, 2020
Copy link
Contributor

@jackyzha0 jackyzha0 left a comment

Choose a reason for hiding this comment

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

small comments but overall some really pog work here dan and michelle!! feel free to check the web notifications box on the main readme too

Comment on lines +19 to +24
const notifyUser = (announcement) => {
const isRecent = new Date() - new Date(announcement.timestamp) < 5000
if (isRecent && notifications.areEnabled()) {
notifications.trigger("New Announcement", announcement.content)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

clean 🧼

// firebase doc that triggered db change event
const changedDoc = querySnapshot.docChanges()[0]

// don't want to notify on 'remove' + 'modified' db events
Copy link
Contributor

Choose a reason for hiding this comment

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

okok I know this is technically out of scope, but thoughts on adding a 'isModified' prop to the Announcement component and add a little edited @ HH:MM:SS message so people know what's been updated

const ToggleSwitchGraphic = styled.div`
width: 35px;
height: 30px;
background: #4F4A59;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think p => p.theme.colors.foreground is this colour exactly

text-align: right;
padding: 0 10px;
bottom: 10px;
color: rgba(0,0,0,.5);
Copy link
Contributor

Choose a reason for hiding this comment

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

is this just half opacity black? what is this supposed to do

Copy link
Contributor Author

Choose a reason for hiding this comment

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

don't think we need this actually

return (
<ToggleSwitchContainer>
<label>
<Input
Copy link
Contributor

Choose a reason for hiding this comment

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

love the semantic HTML here

Comment on lines +4 to +9
export const NOTIFICATION_PERMISSIONS = Object.freeze({
GRANTED: 'granted',
DEFAULT: 'default',
DENIED: 'denied',
})
Copy link
Contributor

Choose a reason for hiding this comment

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

think it should be ok here for now, but if ever need to add more constants then it might be a good idea

Comment on lines +30 to +34
if (notifications.isCurrentPermission(N_PERMISSIONS.DEFAULT)) {
notifications.requestPermission(permission => {
toggleNotifications(permission === N_PERMISSIONS.GRANTED)
})
}
Copy link
Contributor

Choose a reason for hiding this comment

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

is this asking permission to enable notifications for the first time? might be good to add a comment here


useEffect(() => {
setToggled(notifications.areEnabled())
}, [])
Copy link
Contributor

Choose a reason for hiding this comment

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

add setToggled into dependency array

2) add some comments
3) clean up toggle switch styling some more
Copy link
Contributor

@jackyzha0 jackyzha0 left a comment

Choose a reason for hiding this comment

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

pogchamp 🐕

@dryu99 dryu99 merged commit 9e844f6 into master Oct 21, 2020
@dryu99 dryu99 deleted the web-notifications branch October 21, 2020 20:15
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.

4 participants