habitica icon indicating copy to clipboard operation
habitica copied to clipboard

WIP remove challenge tag from list if not in use

Open megansearles opened this issue 2 years ago • 3 comments

Will eventually hopefully fix issue #13844

Changes

In the leaveChallenge method, I saved the output from fetchUserTasks in a variable so I could then see if the tag was in use in any of the user's current tasks. The challenge id is the same as the tag id associated with the challenge, so I searched for that in each task.

If the tag is not used in any of the user's tasks, I dispatch the request to delete the tag. This is where I need a little help. On line 64, I define the tagId so weirdly because if I just put the id itself, the url it sends the request to is "http://localhost:8080/challenges/api/v4/tags/challengeId". I know it's not good to hard code the url like that, but I am just stumped how to have the url actually use the template on line 45 in the below photo. deltag

So, after a couple hours of combing through files and hitting my head on my desk, figured I'd ask some folks who know the code base a lot better


UUID: 56832c8e-2873-45a4-813a-52823288edbd

megansearles avatar Jul 27 '22 03:07 megansearles

still WIP, but I'm not sure anybody saw it, so made it ready for review

megansearles avatar Aug 05 '22 15:08 megansearles

@megansearles do you need a hand with something? If you're still working on it and it's not ready for review, draft status is appropriate!

SabreCat avatar Aug 26 '22 20:08 SabreCat

Hi @SabreCat , yes. On line 64 of the file I changed, I had to hard code the url path instead of just the challengeId parameter because it then still used /challenges/ in the path instead of just starting with localhost. Is there a way to prevent that from happening, so I can just pass in the challenge id, instead of the hard coded path? I think the problem is from using a tag api method while working with challenges

megansearles avatar Aug 26 '22 22:08 megansearles

Hi @megansearles, I'm so sorry for the delay, here. If you're still around, I think the solution is thus:

  1. As you first thought, pass this.challengeId on line 64 of leaveChallengeModal.vue instead of the current workaround
  2. You've uncovered a bug in website/client/src/store/actions/tags.js! All the url constants here need a leading slash / so they don't append to the current URL. Line 45 being
const url = `/api/v4/tags/${payload.tagId}`;

should do the trick.

SabreCat avatar Oct 12 '22 21:10 SabreCat

If I don't hear from you shortly, I'll go ahead and make those changes, and get you your long-overdue contributor credit!

SabreCat avatar Oct 12 '22 21:10 SabreCat