feat: rewrite collab server connecting (#4881)

Co-authored-by: dwelle <luzar.david@gmail.com>
This commit is contained in:
Milos Vetesnik
2022-03-06 22:43:02 +01:00
committed by GitHub
parent 9392ec276d
commit 5ca4f5bbf4
8 changed files with 49 additions and 17 deletions

View File

@ -30,7 +30,25 @@ const generateRoomId = async () => {
return bytesToHexString(buffer);
};
export const SOCKET_SERVER = process.env.REACT_APP_SOCKET_SERVER_URL;
/**
* Right now the reason why we resolve connection params (url, polling...)
* from upstream is to allow changing the params immediately when needed without
* having to wait for clients to update the SW.
*/
export const getCollabServer = async (): Promise<{
url: string;
polling: boolean;
}> => {
try {
const resp = await fetch(
`${process.env.REACT_APP_PORTAL_URL}/collab-server`,
);
return await resp.json();
} catch (error) {
console.error(error);
throw new Error(t("errors.cannotResolveCollabServer"));
}
};
export type EncryptedData = {
data: ArrayBuffer;