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

Kunzite - Allie S. #107

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open

Kunzite - Allie S. #107

wants to merge 15 commits into from

Conversation

azs6189
Copy link

@azs6189 azs6189 commented Jun 28, 2023

No description provided.

Copy link

@spitsfire spitsfire left a comment

Choose a reason for hiding this comment

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

Great job, Allie! You stuck with Learn's structure (ie, keeping a single source of truth with state and functions). Only real feedback I had was removal of unused code and a tweak to the ChatEntry HTML.

</main>
</div>
);
// const [likesCount, setLikesCount] = useState(0);

Choose a reason for hiding this comment

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

Let's remove this line of code since we aren't using it anymore

Suggested change
// const [likesCount, setLikesCount] = useState(0);

const switchHeart = (updatedEntry) => {
const updatedEntries = entries.map((entry) => {
if (entry.id === updatedEntry.id) {
// entry.liked = !entry.liked;

Choose a reason for hiding this comment

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

Suggested change
// entry.liked = !entry.liked;

Comment on lines +44 to +46
{/* Wave 01: Render one ChatEntry component */}

{/* Wave 02: Render ChatLog component */}

Choose a reason for hiding this comment

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

Suggested change
{/* Wave 01: Render one ChatEntry component */}
{/* Wave 02: Render ChatLog component */}

Comment on lines +16 to +18
liked: !props.liked,
};
setLikePost(!likePost);

Choose a reason for hiding this comment

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

Looks like we are updating the chat message data from entries state using the switchHeart. Because of this, we aren't really using likePost or displaying it in our component.

Consider removing lines 8 and 18 completely

Comment on lines +26 to +31
{/* <h2 className="entry-name">Replace with name of sender</h2> */}
<h2 className="entry-name">{props.sender}</h2>
<section className="entry-bubble">
{/* <p>Replace with body of ChatEntry</p> */}
<p>{props.body}</p>
{/* <p className="entry-time">Replace with TimeStamp component</p> */}

Choose a reason for hiding this comment

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

Suggested change
{/* <h2 className="entry-name">Replace with name of sender</h2> */}
<h2 className="entry-name">{props.sender}</h2>
<section className="entry-bubble">
{/* <p>Replace with body of ChatEntry</p> */}
<p>{props.body}</p>
{/* <p className="entry-time">Replace with TimeStamp component</p> */}
<h2 className="entry-name">{props.sender}</h2>
<section className="entry-bubble">
<p>{props.body}</p>

Comment on lines +9 to +22
return (
<div className="chat-log" key={message.id}>
<ChatEntry
id={message.id}
sender={message.sender}
body={message.body}
timeStamp={message.timeStamp}
liked={message.liked}
onUpdate={props.onUpdateHeart}
></ChatEntry>
</div>
);
});
return chatComponents;

Choose a reason for hiding this comment

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

This works! HTML-wise, it is creating a lot of extra div elements that we could clean up by doing the following:

const chatComponents = entries.map((message, index) => {
    return (
        <ChatEntry
            key={message.id}
            id={message.id}
            sender={message.sender}
            body={message.body}
            timeStamp={message.timeStamp}
            liked={message.liked}
            onUpdate={props.onUpdateHeart}
        />
    );
});
return (
    <div className="chat-log">
        {chatComponents}
    </div>
);

Now there is only one div parent surrounding all the ChatEntry components

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants