Skip to content
This repository was archived by the owner on Oct 4, 2023. It is now read-only.

[PAY-176] Implement NotificationPanel redesign#1308

Merged
dylanjeffers merged 4 commits into
mainfrom
dj-pay-176-finalize-desktop-notification-redesign
May 11, 2022
Merged

[PAY-176] Implement NotificationPanel redesign#1308
dylanjeffers merged 4 commits into
mainfrom
dj-pay-176-finalize-desktop-notification-redesign

Conversation

@dylanjeffers

@dylanjeffers dylanjeffers commented May 11, 2022

Copy link
Copy Markdown
Contributor

Description

Implements new NotificationPanel with new redesigned notifications

image

@dylanjeffers dylanjeffers changed the title [PAY-176] Implement NotificationPanel [PAY-176] Implement NotificationPanel redesign May 11, 2022
@audius-infra

Copy link
Copy Markdown
Collaborator

@audius-infra

Copy link
Copy Markdown
Collaborator

)

// Based on how notification types are defined, we need to cast like this.
// In the future we should select user/users/entity/entities in each notif.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

+1. I think ideally the NotificationPanel can use some mapping of NotificationType => Notification element and avoid the wrapper in the future

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah the mapping def makes sense! im not sure if the wrapping is smart enough to figure out that if the type is x, then the component is y, and the prop shape is z, though, if that makes sense?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm thinking in the future these notifs will all have the same props structure so we just pass it in the same to each one, but maybe not?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

they will be diff in the sense that they have BaseNotif, but then other things like value vs reaction vs whatevs i think!

@rickyrombo rickyrombo May 11, 2022

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hmm I'm thinking like:

Somewhere:

notificationTypeMap = {
    [NotificationType.Follow]: FollowNotification,
    //... etc
}

NotificationPanel.tsx:

// ....
       notifications.map(notification =>
           <notificationTypeMap[notification.type] key={notification.id} {...notification} />

Is that what you're thinking?

@dylanjeffers dylanjeffers May 11, 2022

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah the main issue with that with ts though is that Notification is a discriminated union, so we need to get the component from the type, and also merge in the notification with the corresponding type, that's why the switch case works here cause it aligns the notification type so the component + notification type checks correctly, not sure if im being clear!

@rickyrombo rickyrombo May 11, 2022

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Makes sense, gotta appease the typescript engine. Also makes it easier to reason about anyway probably. I'm ok with switch cases, the only slight concern for me is the intermediate React component. I feel like I remember that causing wrapping <divs> and/or having perf implications, but it's been a while and I'm probably wrong and it's not an issue anymore or never was...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah i def hear you on the extra component... will be thinking of a way to make typescript happy while also avoiding a wrapper

const handleClick: MouseEventHandler = useCallback(
event => {
onClick?.(event)
if (!disableClosePanel) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This works, but after thinking about it, what if we don't close the NotificationsPanel on clicks, but rather on navigations? The goal is to close it whenever the user navigates away, right? I guess we'd need both as we probably want to close it on Twitter modal popups? I'm a bit uninformed here for sure.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah this is good thinking for sure! yeah do we want to close in on twitter? we don't currently which i think makes sense. so def agree with the idea that it should be on navigates, how would we do that for the complex interaction of click follow notif with multiple follows -> opens user list modal -> click on a user goes to profile and closes notification? just have an event listener for url changes in panel?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah if we don't currently then no - I'm a little hazy on the ins/outs of when we close it currently sorry! All the route changes should be going through the store, right? Maybe a saga listens for route pushes and put an action to hide notif panel? Seems like a misuse of sagas, but maybe it's fine 😁 Could also be a reducer but i think we slice those up so not sure a notif panel reducer would see the route actions

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

no worries youre thinking is spot on. ill think about things more and see if i come to a sensible way of handling this!

@rickyrombo rickyrombo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One more thing - did we check electron? Saw the panel had some isElectron flag

@dylanjeffers

Copy link
Copy Markdown
Contributor Author

One more thing - did we check electron? Saw the panel had some isElectron flag

that is a good call, i noticed the isElectron was never used in the original code, so looked safe to remove

@dylanjeffers dylanjeffers merged commit 8430e6f into main May 11, 2022
@dylanjeffers dylanjeffers deleted the dj-pay-176-finalize-desktop-notification-redesign branch May 11, 2022 22:55
@sliptype sliptype mentioned this pull request May 13, 2022
dylanjeffers added a commit that referenced this pull request May 18, 2022
raymondjacobson pushed a commit that referenced this pull request May 19, 2022
@AudiusProject AudiusProject deleted a comment from linear Bot Sep 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants