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

Trouble with couchdb #165

Open
bjafl opened this issue Sep 17, 2021 · 2 comments
Open

Trouble with couchdb #165

bjafl opened this issue Sep 17, 2021 · 2 comments

Comments

@bjafl
Copy link

bjafl commented Sep 17, 2021

I've hosted my own couchdb. When testing couch with normal http get/put requests it is working fine. When I enter details in nomie I get a message that it connects and asks if I want to store the credentials. I click yes, but when I change tabs away from settings and back to settings again my couchdb settings are blank. No data are sent to my couchdb server. Any ideas?

@bjafl
Copy link
Author

bjafl commented Sep 17, 2021

I think I've managed to locate the issue. When starting with a fresh instance of nomie, and you fill in the couchdb settings in settings, the settings will not be properly stored in the browser local storage. To be more precise, after the couchdb settings are verified, the credentials are successfully stored in the local storage, but are overwritten moments after. After what I can gather: the saveRemote() function in pouchdb.svelte parses and saves the couchdb settings to the local browser storage, but when the sync is started moments after the startSync() method overwrites the couchdb config in local storage with the object state.remote. At this moment in time, the state.remote object has not been updated with the new couchdb settings, and therefore the valid couchdb config will be overwritten. I found that adding the line state.remote = remote; at the end of the saveRemote() function solves the issue.

I have suggested this as a hotfix in pouchdb.svelte. Honestly I'm not familiar with svelte or npm, so I will leave it to some of your more capable hands to evaluate if this is an appropriate fix for this issue.

@pallavi
Copy link

pallavi commented Feb 9, 2022

in case anyone else runs into this too, i worked around this by manually setting the CouchDB credentials in the localStorage API. i have an iphone + macbook, and i followed these steps:

var dbDetails = localStorage.getItem('n4/storage/pouchdb-remote')
dbDetails = JSON.parse(dbDetails)
dbDetails.url = {YOUR-COUCHDB-URL}
dbDetails.username = {DB-USERNAME}
dbDetails.password = {DB-PASSWORD}
dbDetails.database = {DB-DATABASE-NAME}
localStorage.setItem('n4/storage/pouchdb-remote', JSON.stringify(dbDetails);

then exited and reopened nomie on my phone, and syncing is working!

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

No branches or pull requests

2 participants