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

Implement useReducer for commentFormsVisibility #9862

Merged

Conversation

noi5e
Copy link
Contributor

@noi5e noi5e commented Jun 27, 2021

Part of a React rewrite of the commenting system, see #9365 for more context.

This PR is a follow-up to #9801. In that PR, I started to implement React's useReducer to handle state management, which is becoming more complex.

Basically, #9801 converted state's comments object to useReducer. This PR converts state's commentFormsVisibility to useReducer. commentFormsVisibility is a bit of data in statethat models whether or not an edit/reply comment form is visible on the page


(This issue is part of the larger Comment Editor Overhaul Project with Outreachy. Refer to Planning Issue #9069 for more context)

@gitpod-io
Copy link

gitpod-io bot commented Jun 27, 2021

/* eslint-disable complexity */
import { makeDeepCopy } from "./helpers";

const reducer = (state, action) => {
Copy link

Choose a reason for hiding this comment

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

Function reducer has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.

/* eslint-disable complexity */
import { makeDeepCopy } from "./helpers";

const reducer = (state, action) => {
Copy link

Choose a reason for hiding this comment

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

Function reducer has 47 lines of code (exceeds 25 allowed). Consider refactoring.

@@ -0,0 +1,58 @@
/* eslint-disable complexity */
import { makeDeepCopy } from "./helpers";
Copy link

Choose a reason for hiding this comment

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

Parsing error: 'import' and 'export' may appear only with 'sourceType: module'

@codecov
Copy link

codecov bot commented Jun 27, 2021

Codecov Report

❗ No coverage uploaded for pull request base (main@5c512f0). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #9862   +/-   ##
=======================================
  Coverage        ?   82.09%           
=======================================
  Files           ?       98           
  Lines           ?     5942           
  Branches        ?        0           
=======================================
  Hits            ?     4878           
  Misses          ?     1064           
  Partials        ?        0           

@codeclimate
Copy link

codeclimate bot commented Jun 27, 2021

Code Climate has analyzed commit 0ba49ac and detected 0 issues on this pull request.

View more on Code Climate.

@noi5e noi5e requested a review from jywarren June 30, 2021 05:18
@jywarren jywarren merged commit 80be8ce into publiclab:main Jun 30, 2021
@jywarren
Copy link
Member

Looks great, @noi5e !!!!

17sushmita pushed a commit to 17sushmita/plots2 that referenced this pull request Jul 7, 2021
* implement useReducer for comment state management publiclab#9365

* rename commentFormToggleState to commentFormsVisibility publiclab#9365

* convert commentFormsVisibility state management to useReducer publiclab#9365

* create reducer action for hiding comment form publiclab#9365
@noi5e noi5e deleted the implement-useReducer-comment-forms-textAreas branch July 19, 2021 02:23
reginaalyssa pushed a commit to reginaalyssa/plots2 that referenced this pull request Oct 16, 2021
* implement useReducer for comment state management publiclab#9365

* rename commentFormToggleState to commentFormsVisibility publiclab#9365

* convert commentFormsVisibility state management to useReducer publiclab#9365

* create reducer action for hiding comment form publiclab#9365
billymoroney1 pushed a commit to billymoroney1/plots2 that referenced this pull request Dec 28, 2021
* implement useReducer for comment state management publiclab#9365

* rename commentFormToggleState to commentFormsVisibility publiclab#9365

* convert commentFormsVisibility state management to useReducer publiclab#9365

* create reducer action for hiding comment form publiclab#9365
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants