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

Feat: #482 when Reset topic clicked it should delete comments too #580

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

Conversation

2div
Copy link

@2div 2div commented Dec 1, 2024

Closes #[482]

Description of changes

Additional context

  • A dded a function which will delete comments when Reset topic button clicked
Feat.-.482.mp4

2div and others added 2 commits December 1, 2024 16:18
… too

Added a function which will delete comments when Reset topic button clicked
@2div 2div requested a review from keyserj as a code owner December 1, 2024 13:34
Copy link

netlify bot commented Dec 1, 2024

👷 Deploy request for velvety-vacherin-4193fb pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 44653c5

Copy link

netlify bot commented Dec 1, 2024

Deploy Preview for ameliorate-docs canceled.

Name Link
🔨 Latest commit 44653c5
🔍 Latest deploy log https://app.netlify.com/sites/ameliorate-docs/deploys/67543b7dc31fca00081b72dd

Copy link
Collaborator

@keyserj keyserj left a comment

Choose a reason for hiding this comment

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

Found the issue, see the other PR comments.

Also: I'm assuming this PR is intended to help figure out the bug. FYI for cases like this, you can use a PR draft in order to convey that the PR isn't intended to be thoroughly reviewed for merge yet.


useCommentStore.apiSyncer.pause();
Copy link
Collaborator

Choose a reason for hiding this comment

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

These are changes I made in a separate commit - it seems that when you rebased, you removed these changes. This might separately cause problems for you. The easiest way to fix this right now is probably to just manually add these lines back in, and create a fix commit with that.

What I suspect happened is that when you pulled and saw conflicts, you clicked "accept current changes", which kept your changes and removed the changes being pulled in. In this case, you'd have wanted to keep both your changes and the changes being pulled in (generally if you pull changes that someone else made, you probably want to keep them).

To avoid this in the future, it might help to read up on handling merge conflicts and why/how to rebase. Personally, I think Philomatics does a fantastic job of explaining these concepts:

Additionally, I would fixup (i.e. squash without rewording the original commit's message) said fix commit into your original commit, so that your commit only has your changes, and the commit history is a little cleaner. But you don't have to fixup because I'll handle squashing all commits before merging anyway. If you'd like to look into this, here's another great Philomatics video explaining the interactive rebase, which makes it easy to modify your commit history.

Copy link
Author

Choose a reason for hiding this comment

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

Hey @keyserj , really appreciate you sharing the Philomatics YouTube channel. It was super helpful!

In my last commit, I made a pull request, then committed my changes, and pushed them.

I think you’re right about your note. When I did the pull request, I hit "accept current changes" because I wanted to include my changes, thinking that the other changes would merge in too.

Copy link
Author

Choose a reason for hiding this comment

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

The easiest way to fix this right now is probably to just manually add these lines back in, and create a fix commit with that.

Are you suggesting I should edit the git files in the browser or in VSCode and then push it again?

Copy link
Collaborator

Choose a reason for hiding this comment

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

When I did the pull request, I hit "accept current changes" because I wanted to include my changes, thinking that the other changes would merge in too.

One tip I have is to look at the diff between your branch and the upstream after you've resolved conflicts - the diff should only have your changes, not anyone else's (unless you're aware of their changes and intentionally want to change them). You can use a PR to see this diff or use vscode's gitlens extension to compare HEAD (your latest commit on your checked out branch) with upstream/main to see the same without a PR, like so:

Code_6OHRbZCwXk.mp4

Are you suggesting I should edit the git files in the browser or in VSCode and then push it again?

Generally I would make changes locally (via vscode) so that I can test them before pushing anyway (I'm also less familiar with the browser interface). But in either case you'll need to create a new commit for it (or modify the existing commit, but that's not necessary). Also note that if you use the browser, you'll need to remember to pull those changes locally if you do any further local development.

src/web/comment/store/commentStore.ts Show resolved Hide resolved
@@ -160,6 +160,10 @@ export const deleteComment = (commentId: string) => {
);
};

export const resetComment = () => {
useCommentStore.setState({ ...initialState, comments: [] }, false, "resetComment");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here is the main cause of the error you're seeing: we want to reset to the initial state except for the initial state's topic value, similar to how resetTopicData() is implemented. This is from an unfortunate bit of tech debt 😅 I'm hoping to remove it soon in #581. Essentially if you reset the Topic, we won't know which Topic to make an API request for, preventing the changes from being saved properly.

Side note: you also don't need to set comments: [] here - initialState has that in it already.

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