HomePhabricator
Diffusion Comm 2e65083b0428

[lib][native][web] Use urlPrefix from keysererStore

Description

[lib][native][web] Use urlPrefix from keysererStore

Summary:
issue: https://linear.app/comm/issue/ENG-4459/refactor-urlprefix-field

  1. urlPrefixSelector returns state.urlPrefix if urlPrefix is not present in the keyserverStore as a hack, because the migration will be written in the next diff. This hack should also be undone in the next diff.
  1. useServerCall will need to take the id of the keyserver as an argument. serverCallState will also take this id as an argument. But the urlPrefix for the keyserver with this id might not be found int the keyserverStore (most likely because the keyserver with this id is not present in the keyserverStore at all). I'm currently using an invariant to check this, but me might want to reconsider how this should be handled in the multikeyserver world
  1. In ConnectedLoggedOutModal I'm checking with an invariant if urlPrefix was found. It makes sense as long as we are connected only to one keyserver, because we know the value is set. In multikeyserver world ConnectedLoggedOutModal they will be getting a cookie for each of the keyservers in the keyserverStore, by iterating over them
  1. In SQLiteDataHandler I'm checking with an invariant if urlPrefix was found. urlPrefix is used there to get a new cookie from the keyserver - log the user back and populate the db with data in case of a migartion failure (see https://linear.app/comm/issue/ENG-2071/clear-database-on migration-failure). A new cookie will need to be fetched for all keyservers in the future. (@kamil does this sound right?)
  1. In ConnectedCustomServerModal I'm checking with an invariant if urlPrefix was found. urlPrefix is used there to check whether the typed in url is different from the one we are connected to. In the future we will need to check if it matches any of the keyservers we are connected to, so we will not need this invariant.
  1. ConnectedDevTools: same as ConnectedCustomServerModal. Additionally, the ServerIcon won't be present in the multikeyserver world, because we will be connected to all keyservers on the list.
  1. openSocketSelector and Socket (both web and native): Currently we have a single Socket component that is rendered in the Root component. I'm guessing that once we have multiple keyservers we will have a list of Sockets rendered, and we will be adding and removing items from this list when we connect and disconnect from servers. I'm guessing that the client wanting to connect to a keyserver will ask the identity service for the url of the keyserver it wants to connect to, and then try to open a socket. The Socket will then probably take the id of the keyserver as an argument and will somehow have to deal with the possibility that there is no such keyserver in the keyserverStore. For now we check it with an invariant, but that's probably not ideal in the multikeyserver world

To make sure all of these are adressed at some point, I will create issues / write comments on linear. I will track this in https://linear.app/comm/issue/ENG-4651/document-changes-that-need-to-be-done-mentioned-in-d8814

Test Plan: Checked that web and native work - they connect to the keyserver and it's possible to send messages. Ran yarn flow-all.

Reviewers: michal, kamil

Reviewed By: michal

Subscribers: ashoat, tomek, kamil

Differential Revision: https://phab.comm.dev/D8814

Details

Provenance
inkaAuthored on Aug 15 2023, 6:35 AM
Reviewer
michal
Differential Revision
D8814: [lib][native][web] Use urlPrefix from keysererStore
Parents
rCOMMdce15e9a43d1: [keyserver][lib][native] Add urlPrefix to keyserverStore
Branches
Unknown
Tags
Unknown