rchain-community / rgov

RChain liquid democracy demo: capability sharing, mailbox, directory, chat, ...
https://rchain-community.github.io/rgov/
10 stars 14 forks source link

Help wanted: Allow ballot-UI make use of participate.js #247

Open David405 opened 3 years ago

David405 commented 3 years ago

@dckc I would really appreciate your assistance here, I want to be able to use participate.js functions inside ballot-UI. I tried tweaking the webpack-config but that didn't work, I cannot figure out how the elements in participate.html were called inside participate.js. I can see where these were mounted, but I can't see whether the IDs mounted belong in participate.html.

Creating a separate js file for ballot-UI would be redundant IMO, as the functions to be used by ballot-UI share a lot with the functions and dependencies inside participate.js

dckc commented 3 years ago

What exactly happens when you tried? Exactly what errors did you get? In what way did you tweak webpack-config?

Perhaps push your experiment to a branch and give a log of the exact errors?

jimscarver commented 3 years ago

visual studio finds the reference to ../participate in the import but when it is run the import is not found.

dckc commented 3 years ago

reference from what? "when run" how?

David405 commented 3 years ago

WHAT I DID 1 So I created a file called ballot.js and I imported the function signInfrom participate.js and getEthProviderfrom rchain-api, since I don't know how particpate.js calls elements fromparticipate.html, I manually required the script file ballot.js inside ballot.html as a module ( I know this is bad practice for an SPA, but it is only a temporal solution ). Also, inside of the wepack-config file, I added ballot.html as a HTMLWebpackPlugin.

ERROR So, manually requiring ballot.js even as a module makes the browser unable to find rchain-api or participate.js.

WHAT I DID 2 I tried directly importing the signIn function from participate.js inside index.js and then did a getElementById of #signIn button and added an event listener which calls the function.

ERROR It doesn't look in ballot-ui for the id signIn, so the button does nothing.

NB - I created the signIn function inside participate.js as I didn't want to rewrite existing code, I simply reused the dependencies and methods already created inside participate.js

dckc commented 3 years ago

That all seems reasonable, @David405 . I might be able to reproduce your results, but it would take an hour or so, which I can't justify given other commitments.

If you push the exact code you're running (or attach it as a .zip or something) and share the exact diagnostics you see, I might be able to help in less time.

David405 commented 3 years ago

@dckc kindly check the pull request #250