-
-
Notifications
You must be signed in to change notification settings - Fork 228
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
LB-1688 Feature to thank a user for a pin/recommendation #3143
base: master
Are you sure you want to change the base?
Conversation
Hello @Suvid-Singhal! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2025-01-27 13:01:05 UTC |
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.
Thank you for opening the PR!
There are a couple of things missing before I can test the feature:
Currently, I am recieveing an error on the back-end and two on the front-end.
The back-end one is crashing the web container preventing my testing.
Back-end error:
File "/code/listenbrainz/listenbrainz/webserver/views/user_timeline_event_api.py", line 731
web-1 | raise APIBadRequest(f"{metadata['event_type']} event with id {
web-1 | SyntaxError: unterminated string literal (detected at line 731)
Front-end errors:
First one is easy and just needs renaming the thankFeedEvent
method to avoid name collision:
/code/frontend/js/src/user-feed/UserFeed.tsx
static_builder-1 | 270:15 error 'thankFeedEvent' is already declared in the upper scope on line 268 column 9
Second issue is a typescript type error:
ERROR in ./frontend/js/src/user-feed/UserFeed.tsx:277:27
static_builder-1 | Found 1 error in 13396 ms.
static_builder-1 | TS2339: Property 'blurb_content' does not exist on type 'EventMetadata'.
static_builder-1 | Property 'blurb_content' does not exist on type 'Listen'.
I think at the core of this issue is a misunderstanding of where the thanking logic goes.
The way it is currently set up, clicking on "Thank Event" tries to send a non-existing blurb content via the API (the event you are thanking might not have a blurb content, and if it has one it's not the thank you message).
So instead, clicking on the button should open a modal where the user can write an optional thank you message. The logic for sending the thank-you with the optional blurb content should be implemented in the modal in question instead of the UserFeed page.
A good example of how to do all this is to see how the PersonalRecommendationModal
is used in the ListenCard component, and basically use that as an example for the action button and the new modal.
Hi @MonkeyDo The issue I am facing now is with database. I am getting Database exception while testing. I will have to write SQL scripts and run them on my system to test it but I can't figure it out for now. Will try to fix that as well. Could you please test backend and frontend part and let me know where changes are needed for now? |
I think I know where the DB errors are coming from actually: the 'thanks' event type is missing in the |
Hi @MonkeyDo, |
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.
This set of changes should resolve the blocking issues.
For reference, I just put current_app.logger.info(...
calls at regular intervals to follow where the issue was coming from and isolate the bits of code that were failing, one by one.
While I am here, without doing a full code review of the front-end parts, the UI is looking great. All that is missing is to show the thank events on both users' timelines.
Hi @MonkeyDo, I'm kinda confused on how to proceed. |
OK, let's take a step back for a second because it seems you are trying to add stuff to make it work, without a clear plan or knowing what info you are missing where. Let's think about our issue by analyzing the process step by step.
The only piece of data we are missing at this point is the name of user2. Option 1: To get user2's name, you can retrieve event1 using the original_event_id, using Option 2: when you create the thanks event, either send the thankee_name from the front-end, or on the back-end use the original_event_id and as described above fetch user2's name using the user_id of the original event, then store that in the thanks event metadata in the database. I think option 2 will be easier and faster, at least at retrieval time (we don't need to fetch the original event or the username of the original event creator if we already store that in the thanks event metadata) I think with this limited amount of information, we only want to show a simple UI for now, just the line "user1 thanked user2 for recommendation_type" Regarding your second attempt, the front-end does not send any thanker_username as part of the metadata JSON (here), and when it is received by the back-end endpoint, the event metadata uses that JSON as-is (here), meaning it is created in the DB without the thanker_username. When you try to retrieve it from the DB, the APIThanksEvent class expects a thanker_username in the metadata and does not find it, and throws a validation error. |
One last thing :) For the UI, it's always easiest to first make a mockup of what you want things to look like, before coding it. I usually make my mockups directly in the browser page, modifying the html and css of the page directly from the browser devtools, then take a screenshot of that. |
Hi @MonkeyDo, I think now only frontend part is left cuz it looks really bad as of now 😅 |
I would like you to make a UI mockup as per my last comment. In your case, that means testing the website some more to get a feel for it, and making UI mockups of how you think this feature would best integrate into the feed. Some things to think about:
|
Hi @MonkeyDo,
I like this idea as duplicating the event again and again would clutter the user feed. So, this seems to be a better solution. I can be displayed like a sub-event timeline of the original event. Or we can do it like this as well:
What do you think? |
I think we can go ahead with Option B as it seems easier to implement 😛 and also looks good enough. I think it kinda makes more sense as we won't be putting the thanks event twice in the timeline. And yea, I didn't consider the case when someone thanks a really old recommendation/pin. Recommendations and thank you's do look like a really helpful feature ngl, would love to have it on Spotify as well xD |
Problem
This feature aims to add a functionality to thank users for their pins/recommendations
This feature is a work in progress as of now
Backend is mostly complete but frontend needs some work.
The feature request ticket is: LB-1688
Solution
Implemented backend as of now. Didn't have to change the DB schema for it.
Action
I need some help in some places for frontend in order to complete this.