Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: add notifications widget in the navbar#16983

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
BrunoQuaresma merged 5 commits intomainfrombq/notifications-widget
Mar 18, 2025

Conversation

BrunoQuaresma
Copy link
Collaborator

@BrunoQuaresmaBrunoQuaresma commentedMar 18, 2025
edited
Loading

Preview:
Screenshot 2025-03-18 at 10 38 25

Figma file

This PR adds:

  • Notification widget in the navbar
  • Show notifications
  • Option to mark each notification as read
  • Update notifications in realtime

What is next?

  • Option to mark all the notifications as read at once
  • Option to load previous notifications - Right now, it only shows the latest 25 notifications
  • Having custom icons for each type of notification

And about tests?
The notification widget components are well covered by the current stories, but we definitely want to have e2e tests for it. However, in my recent projects, I found more useful to ship the UI features first, get feedback, change whatever needs to be changed, and then, add the e2e tests to avoid major rework.

Related tocoder/internal#336

@BrunoQuaresmaBrunoQuaresma requested review froma team andbcpeinhardt and removed request fora teamMarch 18, 2025 13:41
Copy link
Member

@ParkreinerParkreiner left a comment

Choose a reason for hiding this comment

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

Looks really good to me overall! Just had a few comments/questions

Comment on lines 142 to 143
const res = JSON.parse(event.data) as TypesGen.GetInboxNotificationResponse;
onNewNotification(res);
Copy link
Member

Choose a reason for hiding this comment

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

TheOneWayWebSocket class handles this, but in the meantime, do we want to add error handling ifJSON.parse ever throws an error?

Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

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

Good catch! I think it is always good to handle errors. In this case, I think we can just log a warn. What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

Just making a note for myself: this looks like a good candidate for swapping in theOneWayWebSocket class oncethat PR is merged in

BrunoQuaresma reacted with thumbs up emoji
Comment on lines 72 to 74
markAllAsRead={(): Promise<void> => {
throw new Error("Function not implemented.");
}}
Copy link
Member

Choose a reason for hiding this comment

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

Just to be on the extra safe side, the return type can be changed tonever to indicate that it will always throw an error. Luckily all promise values are assignable tonever, too, so you don't even needPromise<never>

BrunoQuaresma reacted with thumbs up emoji

type InboxPopoverProps = {
notifications:Notification[] | undefined;
notifications:readonly InboxNotification[] | undefined;
Copy link
Member

Choose a reason for hiding this comment

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

Appreciate thereadonly update!

BrunoQuaresma reacted with thumbs up emoji
useEffect(() => {
const socket = watchInboxNotifications(
(res) => {
safeUpdateNotificationsCache((prev) => {
Copy link
Member

Choose a reason for hiding this comment

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

JavaScript rules will ensure that this works, but just to help make sure the code stays readable, couldsafeUpdateNotificationsCache be moved above the effect?

BrunoQuaresma reacted with thumbs up emoji
Copy link
Member

Choose a reason for hiding this comment

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

Also, I'm really surprised that Biome didn't flag this as a missing effect dependency. I would expect that we would need to wrap the callback inuseEffectEvent, too

BrunoQuaresma reacted with thumbs up emoji
@@ -59,15 +78,15 @@ export const NotificationsInbox: FC<NotificationsInboxProps> = ({

const markNotificationAsReadMutation = useMutation({
mutationFn: markNotificationAsRead,
onSuccess: (_, notificationId) => {
onSuccess: (res) => {
safeUpdateNotificationsCache((prev) => {
Copy link
Member

Choose a reason for hiding this comment

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

Same note, here, too. When I read the code top to bottom, I find it slightly harder to follow the logic when we reference values that haven't been explicitly declared yet

BrunoQuaresma reacted with thumbs up emoji
@BrunoQuaresmaBrunoQuaresma merged commitab8ba96 intomainMar 18, 2025
30 checks passed
@BrunoQuaresmaBrunoQuaresma deleted the bq/notifications-widget branchMarch 18, 2025 18:21
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsMar 18, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@ParkreinerParkreinerParkreiner approved these changes

@bcpeinhardtbcpeinhardtAwaiting requested review from bcpeinhardtbcpeinhardt was automatically assigned from coder/ts

Assignees

@BrunoQuaresmaBrunoQuaresma

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@BrunoQuaresma@Parkreiner

[8]ページ先頭

©2009-2025 Movatter.jp