hoodiehq / hoodie-account-client

:dog: Account client API for the browser
https://hoodiehq.github.io/hoodie-account-client
Apache License 2.0
11 stars 24 forks source link

account.signOut while offline #161

Open amallo opened 7 years ago

amallo commented 7 years ago

Hi,

First of all I don't know if considered as an issue, you should tell me.

I am working on an offline electron's app and Hoodie seems to be great for that but

account.signOut seems to be rejected with this error

{"status":0,"name":"unknown","message":"getCheckpoint rejected with "} while offline,

that sounds wierd to have to be connected to sign out, I am missing something ?

account.signOut works great when server is up

Here is me logout method ignoreLocalChanges param changes nothing

logout: () => {
    return hoodie.account.signOut({ignoreLocalChanges: true})
}

package.json

"@hoodie/client": "^10.1.1",
"pouchdb-browser": "^6.3.4",
gr2m commented 7 years ago

I’m sorry I didn’t get to it today. Long day was long ... I did not forget about it, I’ll try again tomorrow. Maybe someone else will be able to help out quicker

amallo commented 7 years ago

Of course no problem ! I hope you'll find something

Here is my Hoodie initialisation

import Hoodie from '@hoodie/client'
import PouchDB from 'pouchdb-browser'
const hoodie = new Hoodie({
  url: 'http://localhost:8080',
  PouchDB
})
gr2m commented 7 years ago

thanks a lot, I was able to reproduce the issue 👍 I’ll investigate. Would you be interested in contributing a fix? I’d help you out to find your way around and also help to figure out the bug and the fix, but always happy to onboard new contributors and empower folks to help themselves in future :)

amallo commented 7 years ago

Nice ! Sure I can try to help to contribute hope I will find my path :)

gr2m commented 7 years ago

great :) I need to give this some thought first but I’ll get back to you next week.

To give you some background already: we have split up Hoodie into many smaller modules, mostly to force us to create self-contained modules with good APIs, documentation, tests but above all to make contribution easier. So now we have logic for hoodie.account in this repository while we have logic for hoodie.store in the hoodie-store-client repository.

The challenge is now that hoodie.account.signOut() should behave differently based on wether there are local changes in the store or not, so that check would need to go into the hoodie-client repository which combines the two :D In order to make that work for hoodie-client we need ways to "hook" into the signout process from outside the hoodie-account-client, we already have that: https://github.com/hoodiehq/hoodie-account-client#hooks

So now we need to put it all together, I’ll figure this out and then walk you through it. Here is some more info on the overall Hoodie architecture if you are interested: http://docs.hood.ie/en/latest/about/architecture.html

gr2m commented 7 years ago

I’m sorry I didn’t get back to you yet. I’m heads down with work and preparing http://offlinefirst.org/camp/, but I will get back to you after the event, I promise

gr2m commented 6 years ago

I’m so sorry I didn’t get back to you as promised, things went rollercoster last year :( is this still relevant to you?