Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@BrunoQuaresma
Copy link
Contributor

@BrunoQuaresma BrunoQuaresma commented Mar 20, 2025

Users need to see older notifications, so to make that happen, we added a load more button at the end of the notifications list.

Demo:

Screen.Recording.2025-03-20.at.14.51.07.mov

What is missing?
As you can notice, I didn't add tests for this feature. I tried, but I didn't find a good solution for testing scroll events. However I was able to get it working, but it was too cumbersome that I decided to remove because of its maintenence burden.

@BrunoQuaresma BrunoQuaresma self-assigned this Mar 20, 2025
{children}
</ScrollAreaPrimitive.Viewport>
<ScrollBar />
<ScrollBar className="z-10" />
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was getting behind the sticky header.

className={cn([
"[--bottom-offset:48px]",
"[--max-height:calc(var(--radix-popover-content-available-height)-var(--bottom-offset))]",
"[&>[data-radix-scroll-area-viewport]]:max-h-[var(--max-height)]",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tried to make it easier to read the classes and reasoning about their values.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you know what happens if the result of --max-height falls below 0? We're always subtracting 48 no matter what, so I don't know if it makes sense to do a CSS clamp to make sure it can't fall below 0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To make that happen, the screen height would be 48px or less than that. Since this is not a real scenario, even it is possible, I think it is ok to not care about that. Makes sense?

getErrorDetail(error),
);
},
});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just found way easier to use a mutation to update the data than use the useInfiniteQuery and its pages abstraction. Mostly when trying to update the previous query data.

@BrunoQuaresma BrunoQuaresma requested review from a team and aqandrew and removed request for a team March 20, 2025 17:58
Copy link
Contributor

@buenos-nachos buenos-nachos left a comment

Choose a reason for hiding this comment

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

Going to be approving to make sure you're not blocked, but I can't help but feel like the useInfiniteQuery approach would be simpler

I'm going to try taking a crack at refactoring the code to use it later today, and if I can figure something out, open up a second PR with you tagged

<InboxButton unreadCount={unreadCount} />
</PopoverTrigger>
<PopoverContent className="w-[466px]" align="end">
<PopoverContent className="w-[466px] flex flex-col" align="end">
Copy link
Contributor

Choose a reason for hiding this comment

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

Just now noticing: do we want the width to be hard-coded, or could we do something like w-full max-w-[466px]?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think what you proposed is way better. thx

className={cn([
"[--bottom-offset:48px]",
"[--max-height:calc(var(--radix-popover-content-available-height)-var(--bottom-offset))]",
"[&>[data-radix-scroll-area-viewport]]:max-h-[var(--max-height)]",
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you know what happens if the result of --max-height falls below 0? We're always subtracting 48 no matter what, so I don't know if it makes sense to do a CSS clamp to make sure it can't fall below 0

Comment on lines +89 to +90
const lastNotification =
inboxRes.notifications[inboxRes.notifications.length - 1];
Copy link
Contributor

Choose a reason for hiding this comment

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

We want to make sure that notifications isn't empty. Otherwise, lastNotification.id will throw an error on the next line

@BrunoQuaresma
Copy link
Contributor Author

I'm going to try taking a crack at refactoring the code to use it later today, and if I can figure something out, open up a second PR with you tagged

I definitely see value on this. I think I can learn a lot from this 🙏

@BrunoQuaresma BrunoQuaresma merged commit 1593861 into main Mar 21, 2025
30 checks passed
@BrunoQuaresma BrunoQuaresma deleted the bq/infinite-scroll-inbox branch March 21, 2025 16:38
@github-actions github-actions bot locked and limited conversation to collaborators Mar 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants