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

refactor: common discussion approach #3519

Merged

Conversation

benfurber
Copy link
Member

@benfurber benfurber commented May 9, 2024

Description

Until last week I hadn't really appreciated how differently the implementation for discussions on research is from the implementation for discussions on questions.

On questions, the store and component responsibilities are very seperate while for research, the responibilities are highly coupled.

Screenshot 2024-05-20 at 14 31 16

This is a starting point to have a generalised approach to discussions which should make adding discussions to how-tos so much easier.

BREAKING CHANGE: No comment mentions for research. Will add a generalised approach later on. Discussed with Dave.

Now:

Screenshot 2024-05-20 at 14 31 26

To-do:

  • Fix the show/hide button logic
  • Research notifications
  • Fix all the tests, obvs
  • Fix the minor design differences
  • Add unit test coverage for DiscussionWrapper, HideDiscussionContainer, ResearchDisscussion, QuestionDiscussion

Before releasing:

  • Ensure all the prod comments data is in the right places!
  • Add primaryContentId to prod DBs

Write-up tickets:

  • Simplify DiscussionContainer props
  • Implement for how-tos
  • Add custom assertations for comments, replies, notifications
  • Add mentions logic to discussion store
  • Change discussion store to service

@mariojsnunes
Copy link
Collaborator

#3165
Might want to consider the service approach

@benfurber benfurber force-pushed the refactor/common-discussion-approach branch 3 times, most recently from e35a55e to 8f66318 Compare May 16, 2024 11:06
Copy link

cypress bot commented May 16, 2024

1 flaky test on run #5643 ↗︎

0 78 1 0 Flakiness 1

Details:

Merge branch 'master' into refactor/common-discussion-approach
Project: onearmy-community-platform Commit: 41efdaea43
Status: Passed Duration: 04:46 💡
Started: May 21, 2024 12:10 PM Ended: May 21, 2024 12:14 PM
Flakiness  src/integration/research/write.spec.ts • 1 flaky test • ci-chrome

View Output Video

Test Artifacts
[Research] > [Create research article] > [By Authenticated] Test Replay Screenshots Video

Review all test suite changes for PR #3519 ↗︎

@benfurber benfurber force-pushed the refactor/common-discussion-approach branch 4 times, most recently from fbd085e to c133b6f Compare May 17, 2024 16:02
@@ -201,7 +209,7 @@ export class DiscussionStore extends ModuleStore {
}
}

private async _addNotification(
private async _addNotifications(
Copy link
Member Author

Choose a reason for hiding this comment

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

The plan is to move this to a cloud function anyway, so the mess in this function is temporary.

@benfurber benfurber force-pushed the refactor/common-discussion-approach branch from c133b6f to 6257533 Compare May 17, 2024 16:23
Copy link
Collaborator

@mariojsnunes mariojsnunes left a comment

Choose a reason for hiding this comment

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

Some overall comments:

  1. The discussionsStore doesn't really store anything related do discussions, it just calls firebase and the data is stored in the DiscussionWrapper. Other than calling firebase, the only use of the store is to access the activeUser from the RootStore.
    If we call the userStore at the DiscussionWrapper to access the activeUser, we could remove the dependency on RootStore and mobx and rename the class to DiscussionService.
  2. QuestionDiscussion and ResearchComments don't do much now, maybe can be removed in favor of using DiscussionWrapper directly?
  3. Maybe the #update- logic could be simplified by just using the commentId and if the comment/discussion access the location hash directly.

src/common/DiscussionWrapper.tsx Outdated Show resolved Hide resolved
src/common/HideDiscussionContainer.tsx Outdated Show resolved Hide resolved
const { discussionStore } = useCommonStores().stores
const highlightedCommentId = window.location.hash.replace('#comment:', '')

const transformComments = (discussion) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe there could be a const comments = useMemo(() => ,[discussion, activeUser]) that automatically transforms the comments when the discussion or activeUser changes.
So when there is a discussion update, you simply update the discussion state, the useMemo takes care of the rest and can pass the comments to the discussionProps.

@benfurber benfurber force-pushed the refactor/common-discussion-approach branch from 6257533 to 32e12f3 Compare May 20, 2024 09:30
@benfurber benfurber marked this pull request as ready for review May 20, 2024 13:32
@benfurber benfurber requested a review from a team as a code owner May 20, 2024 13:32
@benfurber benfurber force-pushed the refactor/common-discussion-approach branch from c71e5f5 to b257705 Compare May 20, 2024 16:06
@benfurber benfurber force-pushed the refactor/common-discussion-approach branch from b257705 to 98350c2 Compare May 20, 2024 16:11
Copy link

codecov bot commented May 20, 2024

Codecov Report

Attention: Patch coverage is 71.62162% with 42 lines in your changes are missing coverage. Please review.

Project coverage is 68.01%. Comparing base (d8f9c8c) to head (41efdae).
Report is 7 commits behind head on master.

Files Patch % Lines
src/common/DiscussionWrapper.tsx 59.01% 24 Missing and 1 partial ⚠️
src/stores/Discussions/discussions.store.tsx 54.28% 16 Missing ⚠️
src/stores/Discussions/discussionEvents.ts 94.73% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3519      +/-   ##
==========================================
- Coverage   68.10%   68.01%   -0.10%     
==========================================
  Files         441      443       +2     
  Lines       13973    13871     -102     
  Branches     2507     2493      -14     
==========================================
- Hits         9516     9434      -82     
+ Misses       4408     4389      -19     
+ Partials       49       48       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@benfurber
Copy link
Member Author

@mariojsnunes From your comments:

  1. Moving QuestionStore to QuestionService. I'm with you on that approach. I'll do a ticket for it so this large branch doesn't have to get larger.
  2. On the size of QuestionDiscussion and ResearchDiscussion. Maybe. But I'd rather keep moving in the direction of getting components smaller before deciding whether some are too small.
  3. The #update- logic. Hadn't engaged with it at all in this PR.
  4. useMemo Would you be up for applying that to DiscussionWrapper in a follow-up PR? I spend some time on it yesterday and just made a mess.

@benfurber benfurber force-pushed the refactor/common-discussion-approach branch from 98350c2 to 58a9a94 Compare May 21, 2024 09:34
@davehakkens davehakkens added the Review allow-preview ✅ Has received manual check for malicious code and can be safely built for preview label May 22, 2024
Copy link
Contributor

github-actions bot commented May 22, 2024

Visit the preview URL for this PR (updated for commit 41efdae):

https://onearmy-next--pr3519-refactor-common-disc-32cd70a3.web.app

(expires Fri, 21 Jun 2024 13:52:44 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 6d65e4f8fee2f6ab2da0c1c3b85b8797d66afa59

@benfurber benfurber merged commit 3ad1e05 into ONEARMY:master May 22, 2024
22 checks passed
@onearmy-bot
Copy link
Collaborator

🎉 This PR is included in version 1.182.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@onearmy-bot
Copy link
Collaborator

🎉 This PR is included in version 1.185.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Mod: Research 🔬 released Review allow-preview ✅ Has received manual check for malicious code and can be safely built for preview
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

5 participants