Skip to content
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

Comments 💬 (backend + frontend) #1153

Merged
merged 21 commits into from
Jun 7, 2021

Conversation

tudi2d
Copy link
Member

@tudi2d tudi2d commented May 17, 2021

PR Checklist

  • - Latest master branch merged
  • - PR title descriptive (can be used in release notes)

PR Type

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

First implementation of the comments to be merged.

Comments can't be edited from the FE site right now - they can only be deleted. This should be ok for the first release, but could be added afterwards. Admins & comment creators are allowed to remove comments.

Combine PR #1145 & #1146

Git Issues

Closes #1127 & Closes #1128

Screenshots/Videos

2KqKRqMsUG

@tudi2d tudi2d added Review: Assigned 👉 Waiting on review from a specific dev Review allow-preview ✅ Has received manual check for malicious code and can be safely built for preview labels May 17, 2021
@tudi2d tudi2d requested a review from chrismclarke May 17, 2021 10:41
@tudi2d tudi2d self-assigned this May 17, 2021
@tudi2d
Copy link
Member Author

tudi2d commented May 17, 2021

@danitrod Your work made it really easy to build on! Thanks man! If you have any suggestions/things to be changed let me know :)

@davehakkens Here is the combined version of the PRs

@github-actions
Copy link
Contributor

github-actions bot commented May 17, 2021

Visit the preview URL for this PR (updated for commit 4fb978b):

https://onearmy-next--pr1153-comments-combined-hca4yv9i.web.app

(expires Wed, 07 Jul 2021 05:11:49 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

@davehakkens
Copy link
Contributor

yeahh nice work @tudi2d and @danitrod.

Few comments from my side after some testing
Important ones:
1. Deletion bug: In some way I ended up deleting your very controversial skateboard comment Philipp. I wanted to delete one of my own but yours seems to be removed as well. (was not logged in as admin)
2. Input field character limit Currently there is no limit. Should be set to 400 characters (original was 200 but might be to little)

Minor ones
3. Icon change The icon you see (currently the pink hand) should be in sync with your profile icon (workspace, collectionpoint, machineshop, member etc.) So it's the same as the one you see in the right top corner to go to your profile
4 Change location doesn't change flag If I change my location it changes the flag in my profilee But it doesn't change the flag on my comments. Ideally they are changed everywhere

@danitrod
Copy link
Collaborator

Thank you Dave, I'll tackle on points 1 and 4 as they're more related to back-end. Point 2 I think both of us can work on, I'll add a functionality for the back-end function to crop the comment to have length 400 if it comes with more than that, but the input field in the front-end should not allow more than 400 chars as well.

Is that ok @tudi2d?

@danitrod
Copy link
Collaborator

@davehakkens about 1, confirmed bug, I just accidentally deleted your test comments by deleting one of mine. I'll take a look into why that's happening.

@danitrod danitrod mentioned this pull request May 18, 2021
5 tasks
@tudi2d
Copy link
Member Author

tudi2d commented May 18, 2021

Looks like this now.

image

@tudi2d tudi2d added Review allow-preview ✅ Has received manual check for malicious code and can be safely built for preview and removed Review allow-preview ✅ Has received manual check for malicious code and can be safely built for preview Backend labels May 18, 2021
@davehakkens
Copy link
Contributor

Visit the preview URL for this PR (updated for commit 5e36e07):

https://onearmy-next--pr1153-comments-combined-hca4yv9i.web.app

(expires Thu, 17 Jun 2021 17:34:18 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Do you test it with that url? Doesn't seem to show any changes here..
Locally I can see them, looks good! But I can't post/test anything.

But perhaps it has to do with the Pull requests stacked on top of eachother?

@tudi2d
Copy link
Member Author

tudi2d commented May 19, 2021

I adjusted the styles - should look like intended now. Not sure about the error with posting things - @danitrod any idea?
image

@davehakkens
Copy link
Contributor

nice looking good. One last thing for you @tudi2d Would be nice if you could align the text and remove the text limed when not logged in
afbeelding

@danitrod
Copy link
Collaborator

I adjusted the styles - should look like intended now. Not sure about the error with posting things - @danitrod any idea?
image

How did you get that error? I'm not being able to reproduce here

@tudi2d
Copy link
Member Author

tudi2d commented May 19, 2021

How did you get that error? I'm not being able to reproduce here

I used the version deployed on the preview URL & tried to enter a comment.

@danitrod
Copy link
Collaborator

how weird - for me this isn't happening; is there any more information in the error so I can better debug? Also if you could check what was the sent payload in the request from the network devtool that might help

- Center not logged in text
@tudi2d
Copy link
Member Author

tudi2d commented May 19, 2021

It looked like this:
tnCWLSckEk

I think, I fixed it for me - @davehakkens does it work for you now as well? The issue was, that the country was set to undefined & firebase does not like that (as undefined seems like a none intended, missing value - null is the way to go). Difficult to debug without the information indeed...

image

@davehakkens
Copy link
Contributor

I'm testing with that url, not sure if that is the best way. But posting seems to work now.
However, the country flag still doesn't update here @danitrod?
Comments:
afbeelding
Profile:
afbeelding

@davehakkens
Copy link
Contributor

Woops and I found one more thing @danitrod!
You are now showing the "Display name" and it should show the "Username".
so for instance Precious Plastic Headquarters should be precious-plastic
So it's consistent throughout the platform.

Sorry for not seeing this one sooner or making it more clear in the first place. 🙏

★ as a bonus you could also make it link to the user profile. But no need. We can also do it in an issue later

@tudi2d
Copy link
Member Author

tudi2d commented May 19, 2021

I will create an issue for the link to the profile, so it can be worked on after the PR is merged. It should be a good & easy follow up.

My suggestion would be to change the "Display name" & "Username" & than let @chrismclarke review the PR maybe, as this is already becoming a bigger PR. Not sure how hard fixing the flag issue is, but in my opinion a country change is (for the most users & workspaces) probably more of an edge case. It's great, that we already catched it & if it's not easy to fix it could also be a good follow up (as it is more of an improvement, than a bug to the comments). What do you guys think?

@davehakkens
Copy link
Contributor

yeh good point, getting big indeed! Your proposal sounds good to me

@danitrod
Copy link
Collaborator

danitrod commented May 20, 2021

Nice catch @tudi2d ! Definitely difficult to debug, thank you. @davehakkens about updating information when the user updates, unfortunately the Firebase functions aren't deployed with the preview as far as I know, so we can't know if it's working yet - I left a note here #1146 (comment). We'll need Chris' help to check on how to test that.

I agree we this PR is getting a bit overloaded, I will update the comments to use username and not displayname and I guess we can merge after the review.

Edit: just pushed a commit to the back-end PR with the userName fix

@tudi2d
Copy link
Member Author

tudi2d commented May 20, 2021

Looks good! I liked, how we worked on this really asynchronously across time zones & still build it rather fast (for a free time project) - good communication & quality work from your site @danitrod! 🙂 Thanks for the feedback & testing @davehakkens!

@chrismclarke
Copy link
Member

Sorry, I know I've been slow to review this, have got held up by a bunch of core build issues not working correctly. Will do my best to find time this week once the rest of the build is stable again.

Copy link
Member

@chrismclarke chrismclarke left a comment

Choose a reason for hiding this comment

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

Really nice job here, thanks so much for all you've done @danitrod and @tudi2d.

The codebase looks pretty solid to me, I think there'll likely a few minor UI changes required and be good to get some more user input before going live so I'll add a beta-tester authwrapper to keep it only viewable by admins/beta-testers, but otherwise definitely happy to merge.

I really appreciate that you also took some time to think about challenges with things like users changing names - for me this is a major sticking point of the current database setup making these types of modules much harder to implement (than say, graphql where you could query and merge users names, countries etc. as you retrieve the comments). But I think what you've done is as good as we can hope for short term so thanks for finding a way to work in the constraints.

import { backupUser } from './backupUser'

/*********************************************************************
* Side-effects to be carried out on various user updates, namely:
* - create user revision history
* - update map pin location on change
* - update howTo creator flag on change
* - update userName and flag on any comments made by user
Copy link
Member

Choose a reason for hiding this comment

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

I didn't know you could even change username! I think this leaves us with a few challenges to figure out, but good to have included in the comment update. Longer term we will probably need a refactor to keep user id independent of user name (I can't remember why we didn't do that in the first place - possibly to make serving the avatar image easier)... but in any case good to have this here for now

@@ -11,7 +23,10 @@ export interface IHowto extends IHowtoFormInput, IModerable {
cover_image: IUploadedFileMeta
files: Array<IUploadedFileMeta | File | null>
steps: IHowtoStep[]
// Comments were added in V2, old howto's may not have the property
comments?: IComment[]
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for adding the comment to explain this

const user = stores.userStore.activeUser

async function keyDown(e) {
if (e.key === 'Enter' && !e.shiftKey && comment.trim().length) {
Copy link
Member

Choose a reason for hiding this comment

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

Nice idea to add this, would definitely expect pressing the enter key to submit. I'm not sure if you can achieve the same functionality using simple form elements (e.g. https://stackoverflow.com/questions/33211672/how-to-submit-a-form-using-enter-key-in-react-js/33212911), but happy to keep this in to be more explicit (and add the empty check)

@@ -136,6 +138,107 @@ export class HowtoStore extends ModuleStore {
return needsModeration(howto, toJS(this.activeUser))
}

Copy link
Member

Choose a reason for hiding this comment

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

I think likely we will want to reuse comments in other pages, so might be better to try and separate out into its own store or set of methods. But happy to keep here for now and can always refactor later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backend Mod: HowTo 📰 Review allow-preview ✅ Has received manual check for malicious code and can be safely built for preview Review: Assigned 👉 Waiting on review from a specific dev
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Comments! 💬 (back end) Comments! 💬 (front end)
4 participants