fix storage

As discussed, loads:
Description - was already in place, didn't change it.
instanceId - this is still generated per network per userId
consent state with remote instances.
Honestly what's the point of restoring something from storage if it will be
immediately overwritten.

Maybe we should not store instanceId, description and keyHash to storage?

On Wed, Oct 29, 2014 at 4:28 PM, dborkan <notifications@github.com> wrote:

> In src/generic_core/remote-instance.ts:
>
> >        // Load consent state if it exists.  The consent state does not exist when
> >        // processing an initial instance handshake, only when restoring one from
> >        // storage.
> > -      if (consent) {
> > -        this.consent = consent;
> > -      }
> > +      this.instanceId = data.instanceId;
> > +      storage.load<RemoteInstanceState>(this.getStorePath())
> > +          .then((state) => {
> > +            this.restoreState(state);
> > +          }).catch((e) => {
> > +            console.log('Did not have consent state for this instanceId');
> > +          });
> > +
> >        this.bytesSent = 0;
> >        this.bytesReceived = 0;
> >        this.update(data);
>
> I think you need to move (or duplicate) this.update inside the then and
> catch blocks after storage.load. storage.load is async right? If so you
> will still end up calling this.update(data) before this.restoreState(state)
> with the way things are currently written - meaning you will overwrite new
> values with old ones
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/uProxy/uproxy/pull/527/files#r19569872>.
>