-
Notifications
You must be signed in to change notification settings - Fork 327
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(kudos): display notification when kudos received #9199
Merged
Merged
Changes from 10 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
8773dee
chore(kudos): add kudos team settings
igorlesnenko 0427b07
store emoji id
igorlesnenko 598c526
chore(kudos): add kudos record when adding emoji reaction
igorlesnenko 9778c04
Fix snackbar
igorlesnenko 83f6490
quick fix for types
igorlesnenko e66353e
Dynamic emoji
igorlesnenko 29720e2
del console log
igorlesnenko 91bb210
feat(kudos): display notification when kudos received
igorlesnenko 53bf03b
Remove comment
igorlesnenko 673ac2a
Update notification text
igorlesnenko b69ae92
Remove unused kudos field
igorlesnenko c5abfd4
expose senderUser
igorlesnenko abb27b6
Fix reactable type
igorlesnenko 82dcec4
Fix table name
igorlesnenko 1d5a2dd
remove unused fields
igorlesnenko 6d91805
Don't check feature flag
igorlesnenko 411d13d
Fix analytics
igorlesnenko d7c9052
Add snackbar events
igorlesnenko 5c0a450
fix typescript
igorlesnenko fb2ceb5
Merge branch 'kudos-add-kudoses-with-reactji' of github.com:ParabolIn…
igorlesnenko 61e78bf
Fix type
igorlesnenko 7df1911
Fix type
igorlesnenko 8d14989
add notification status analytics
igorlesnenko 50d28f3
Fix type
igorlesnenko 7144fae
fix type
igorlesnenko b927334
Fix table name caused by wrong merge
igorlesnenko f736929
add snackbar clicked event to kudosReceived snackbar
igorlesnenko cc942c8
Merge branch 'master' into kudos-receiver-notification
igorlesnenko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import graphql from 'babel-plugin-relay/macro' | ||
import {Link} from 'react-router-dom' | ||
import React, {useEffect} from 'react' | ||
import {useFragment} from 'react-relay' | ||
import {KudosReceivedNotification_notification$key} from '~/__generated__/KudosReceivedNotification_notification.graphql' | ||
import NotificationTemplate from './NotificationTemplate' | ||
import useAtmosphere from '../hooks/useAtmosphere' | ||
import SendClientSideEvent from '../utils/SendClientSideEvent' | ||
import getReactji from '~/utils/getReactji' | ||
|
||
interface Props { | ||
notification: KudosReceivedNotification_notification$key | ||
} | ||
|
||
const KudosReceivedNotification = (props: Props) => { | ||
const atmosphere = useAtmosphere() | ||
const {notification: notificationRef} = props | ||
const notification = useFragment( | ||
graphql` | ||
fragment KudosReceivedNotification_notification on NotifyKudosReceived { | ||
...NotificationTemplate_notification | ||
id | ||
type | ||
name | ||
picture | ||
meetingName | ||
meetingId | ||
emoji | ||
} | ||
`, | ||
notificationRef | ||
) | ||
const {type, name, picture, meetingName, emoji, meetingId} = notification | ||
|
||
const {unicode} = getReactji(emoji) | ||
|
||
useEffect(() => { | ||
SendClientSideEvent(atmosphere, 'Notification Viewed', { | ||
notificationType: type | ||
}) | ||
}, []) | ||
|
||
return ( | ||
<NotificationTemplate | ||
message={ | ||
<> | ||
{unicode} {name} gave you kudos in{' '} | ||
<Link to={`/meet/${meetingId}`} className='font-semibold text-sky-500 underline'> | ||
{meetingName} | ||
</Link> | ||
</> | ||
} | ||
notification={notification} | ||
avatar={picture} | ||
/> | ||
) | ||
} | ||
|
||
export default KudosReceivedNotification |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
packages/client/mutations/toasts/mapKudosReceivedToToast.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import graphql from 'babel-plugin-relay/macro' | ||
import {Snack} from '../../components/Snackbar' | ||
import {mapKudosReceivedToToast_notification$data} from '../../__generated__/mapKudosReceivedToToast_notification.graphql' | ||
import makeNotificationToastKey from './makeNotificationToastKey' | ||
import {OnNextHistoryContext} from '../../types/relayMutations' | ||
import SendClientSideEvent from '../../utils/SendClientSideEvent' | ||
import getReactji from '~/utils/getReactji' | ||
|
||
graphql` | ||
fragment mapKudosReceivedToToast_notification on NotifyKudosReceived { | ||
id | ||
name | ||
meetingName | ||
meetingId | ||
emoji | ||
} | ||
` | ||
|
||
const mapKudosReceivedToToast = ( | ||
notification: mapKudosReceivedToToast_notification$data, | ||
{atmosphere, history}: OnNextHistoryContext | ||
): Snack => { | ||
const {id: notificationId, meetingName, name, emoji, meetingId} = notification | ||
const {unicode} = getReactji(emoji) | ||
return { | ||
autoDismiss: 5, | ||
showDismissButton: true, | ||
key: makeNotificationToastKey(notificationId), | ||
message: `${unicode} ${name} gave you kudos in`, | ||
action: { | ||
label: meetingName, | ||
callback: () => { | ||
history.push(`/meet/${meetingId}`) | ||
} | ||
}, | ||
onShow: () => { | ||
SendClientSideEvent(atmosphere, 'Snackbar Viewed', { | ||
snackbarType: 'kudosReceived' | ||
}) | ||
} | ||
} | ||
} | ||
|
||
export default mapKudosReceivedToToast |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
packages/server/database/types/NotificationKudosReceived.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import Notification from './Notification' | ||
|
||
interface Input { | ||
userId: string | ||
name: string | ||
picture: string | ||
senderUserId: string | ||
meetingName: string | ||
meetingId: string | ||
emoji: string | ||
} | ||
|
||
export default class NotificationKudosReceived extends Notification { | ||
readonly type = 'KUDOS_RECEIVED' | ||
name: string | ||
picture: string | ||
senderUserId: string | ||
meetingName: string | ||
meetingId: string | ||
emoji: string | ||
|
||
constructor(input: Input) { | ||
const {userId, name, picture, senderUserId, meetingName, meetingId, emoji} = input | ||
super({userId, type: 'KUDOS_RECEIVED'}) | ||
this.name = name | ||
this.picture = picture | ||
this.senderUserId = senderUserId | ||
this.meetingName = meetingName | ||
this.meetingId = meetingId | ||
this.emoji = emoji | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
+1 This seems to send a client event for every kudos notification in the dropdown every time the user opens the notification dropdown menu.
Would it be more helpful to only send the client event if it's unread?
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.
I made it similar to other notifications. @tghanken what do you think?
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.
I think this is fine as is. It could be helpful to add "isRead" ads a boolean parameter if it's easy!
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.
we have notification status, CLICKED, READ etc. As an option, I can add it as is