habitica
habitica copied to clipboard
WIP remove challenge tag from list if not in use
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.
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
still WIP, but I'm not sure anybody saw it, so made it ready for review
@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!
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
Hi @megansearles, I'm so sorry for the delay, here. If you're still around, I think the solution is thus:
- As you first thought, pass
this.challengeId
on line 64 ofleaveChallengeModal.vue
instead of the current workaround - You've uncovered a bug in
website/client/src/store/actions/tags.js
! All theurl
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.
If I don't hear from you shortly, I'll go ahead and make those changes, and get you your long-overdue contributor credit!