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

Remove my vote #18

Open
iSapozhnik opened this issue Feb 21, 2023 · 6 comments
Open

Remove my vote #18

iSapozhnik opened this issue Feb 21, 2023 · 6 comments
Labels

Comments

@iSapozhnik
Copy link

Is there a way to remove my vote?
For instance I voted for one feature but then I. saw another one which I actually like more and don't want the first one anymore. I would expect that clicking on the feature I voted before will reset it back.

Thanks

@jordibruin
Copy link
Collaborator

They're not an easy way to do that with countapi.xyz (although there is a way). Lets investigate!

@iSapozhnik
Copy link
Author

Yeah I see. Just sniffed the traffic to check what does it return (like if there is an ID we can store locally) but no - nothing. 🤔 I'm afraid with the countAPI it's not even possible.

@jordibruin
Copy link
Collaborator

It is possible with the /set/ endpoint

/set/:namespace?/:key?value=:value

Set the value of a key. Optionally specify the namespace. The key must be created with enable_reset set to 1 (true).

This endpoint will return the previous value before the assignation.

We would have to save the current votes and then set it to one below that.

@vdhamer
Copy link
Contributor

vdhamer commented Mar 18, 2023

It is possible with the /set/ endpoint
/set/:namespace?/:key?value=:value
Set the value of a key. Optionally specify the namespace. The key must be created with enable_reset set to 1 (true).
This endpoint will return the previous value before the assignation.
We would have to save the current votes and then set it to one below that.

The /set endpoint would do the trick. Sidenote: as I read the docs, you can set a counter value to any new value.
But /set only works if you use /create with parameters like enable_reset=true.
But I tried, and even the examples in the /create API documentation don't work for any of create's parameter.

My guess is that, because api.countapi.xyz got sold, the new owner may have disabled some features unless you pay. See sale of countapi in 2021.

Alternatives for us:

  • contact new countapi owner (might just be a bug). At least the API docs for /create need updating.
    [ Update 19 March: can't find CountAPI in the offering of apilayer.com ]
  • contact original author @mlomb of countAPI.
  • with /create you can create default counters that can be incremented and decremented by 1. But, because you are stuck with using only default parameters, you end up with namespace 'default' with key=UUID (hmmm). Pretty ugly, but that would allow you to create as many custom keys as you need. This thus means replacing the /hit endpoint partly with /create and storing the created UUID names in userDefaults.
  • app just emphasises to the user that cast votes cannot be withdrawn (I took this approach so far) and preferably the app request confirmation. I am more worried about accidentally pressing the button than users changing their minds. I didn't quite get this to work yet (as a a custom wrapper around the default FeatureVoter struct).

@mlomb
Copy link

mlomb commented Mar 19, 2023

Hi, original author of CountAPI here.
Yes, the only way to reduce a counter is using /set with enable_reset=1. If it doesn't work it must be a bug 😢. I think APILayer hasn't changed the code at all for now.

@jordibruin
Copy link
Collaborator

@mlomb thanks so much for creating countapi! 🥰

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

No branches or pull requests

4 participants