uprtcl / js-uprtcl

Libraries, tools and modules to create _Prtcl web apps
http://www.uprtcl.io/
Other
43 stars 13 forks source link

Show home space by default #226

Closed pepoospina closed 3 years ago

pepoospina commented 4 years ago

When a user enters home.ts of linked-thoughts and is logged in, it should get its home perspective, and if the perspective does not exist, he should create it. Once the perspective is created, it should be rendered using a new web-component called

pepoospina commented 4 years ago

In the app home, replace the create document with a default document id derivation (the "document" is the home space)

async newDocument(title: string) {
    this.creatingNewDocument = true;

    const remote = this.requestAll(EveesModule.bindings.EveesRemote).find((provider: EveesRemote) =>
      provider.id.startsWith('http')
    ) as EveesRemote;

    const perspective = await remote.getHome(remote.userId);
    const id = await remote.store.create(perspective.object);

    if (id !== perspective.id) {
      throw new Error('unexpected id');
    }

    this.go(perspective.id);
  }

In the evees.http.ts, add the getHome method

async getHome(userId?: string) {
    if (!userId) throw new Error('user id must be defined');

    this.logger.warn('remote random int when done');
    const remoteHome = {
      remote: this.id,
      path: '',
      creatorId: userId,
      timestamp: 0,
      context: `home`
    };

    return deriveSecured(remoteHome, this.store.cidConfig);
  }

Now the app should render the home perspective of the user always

pepoospina commented 4 years ago

Since you are working on an old version, patch the evees.remote.ts interface to add the getHome method

pepoospina commented 4 years ago

Missing changes