From e30d4e67463144f44617da5f8b5bfc626f6ae492 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Mon, 27 Sep 2021 09:31:34 +0200 Subject: [PATCH] Convert boundThreepid to TS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/{boundThreepids.js => boundThreepids.ts} | 8 ++++++-- src/utils/promise.ts | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) rename src/{boundThreepids.js => boundThreepids.ts} (84%) diff --git a/src/boundThreepids.js b/src/boundThreepids.ts similarity index 84% rename from src/boundThreepids.js rename to src/boundThreepids.ts index 3b32815913..94ff36ad4f 100644 --- a/src/boundThreepids.js +++ b/src/boundThreepids.ts @@ -14,9 +14,13 @@ See the License for the specific language governing permissions and limitations under the License. */ +import { IThreepid, ThreepidMedium } from "matrix-js-sdk/src/@types/threepids"; +import { MatrixClient } from "matrix-js-sdk/src/client"; import IdentityAuthClient from './IdentityAuthClient'; -export async function getThreepidsWithBindStatus(client, filterMedium) { +export async function getThreepidsWithBindStatus( + client: MatrixClient, filterMedium?: ThreepidMedium, +): Promise { const userId = client.getUserId(); let { threepids } = await client.getThreePids(); @@ -31,7 +35,7 @@ export async function getThreepidsWithBindStatus(client, filterMedium) { const identityAccessToken = await authClient.getAccessToken({ check: false }); // Restructure for lookup query - const query = threepids.map(({ medium, address }) => [medium, address]); + const query = threepids.map(({ medium, address }): [string, string] => [medium, address]); const lookupResults = await client.bulkLookupThreePids(query, identityAccessToken); // Record which are already bound diff --git a/src/utils/promise.ts b/src/utils/promise.ts index 853c172269..abcfc49a08 100644 --- a/src/utils/promise.ts +++ b/src/utils/promise.ts @@ -16,8 +16,8 @@ limitations under the License. // Returns a promise which resolves when the input promise resolves with its value // or when the timeout of ms is reached with the value of given timeoutValue -export async function timeout(promise: Promise, timeoutValue: T, ms: number): Promise { - const timeoutPromise = new Promise((resolve) => { +export async function timeout(promise: Promise, timeoutValue: Y, ms: number): Promise { + const timeoutPromise = new Promise((resolve) => { const timeoutId = setTimeout(resolve, ms, timeoutValue); promise.then(() => { clearTimeout(timeoutId);