Move to websocket for requests to signal server

This commit is contained in:
Fedor Indutny
2021-07-28 14:37:09 -07:00
committed by GitHub
parent 8449f343a6
commit 1c1d0e2da0
31 changed files with 1892 additions and 1336 deletions

View File

@@ -14,6 +14,7 @@ import {
import * as Bytes from '../Bytes';
import { longRunningTaskWrapper } from '../util/longRunningTaskWrapper';
import { isGroupV1 } from '../util/whatTypeOfConversation';
import { explodePromise } from '../util/explodePromise';
import type { ConversationAttributesType } from '../model-types.d';
import type { ConversationModel } from '../models/conversations';
@@ -175,7 +176,7 @@ export async function joinViaLink(hash: string): Promise<void> {
};
// Explode a promise so we know when this whole join process is complete
const { promise, resolve, reject } = explodePromise();
const { promise, resolve, reject } = explodePromise<void>();
const closeDialog = async () => {
try {
@@ -405,26 +406,3 @@ function showErrorDialog(description: string, title: string) {
},
});
}
function explodePromise(): {
promise: Promise<void>;
resolve: () => void;
reject: (error: Error) => void;
} {
let resolve: () => void;
let reject: (error: Error) => void;
const promise = new Promise<void>((innerResolve, innerReject) => {
resolve = innerResolve;
reject = innerReject;
});
return {
promise,
// Typescript thinks that resolve and reject can be undefined here.
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
resolve: resolve!,
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
reject: reject!,
};
}