Handle rate limits when upgrading from a guest account
This commit is contained in:
parent
7d44a1e979
commit
59938cd46b
1 changed files with 9 additions and 1 deletions
|
@ -16,6 +16,8 @@ limitations under the License.
|
||||||
|
|
||||||
import React, { useCallback, useEffect, useRef, useState } from "react";
|
import React, { useCallback, useEffect, useRef, useState } from "react";
|
||||||
import { useHistory, useLocation } from "react-router-dom";
|
import { useHistory, useLocation } from "react-router-dom";
|
||||||
|
import { captureException } from "@sentry/react";
|
||||||
|
import { sleep } from "matrix-js-sdk/src/utils";
|
||||||
import { FieldRow, InputField, ErrorMessage } from "../input/Input";
|
import { FieldRow, InputField, ErrorMessage } from "../input/Input";
|
||||||
import { Button } from "../button";
|
import { Button } from "../button";
|
||||||
import { useClient } from "../ClientContext";
|
import { useClient } from "../ClientContext";
|
||||||
|
@ -81,7 +83,13 @@ export function RegisterPage() {
|
||||||
try {
|
try {
|
||||||
await newClient.joinRoom(roomId);
|
await newClient.joinRoom(roomId);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn(`Couldn't join room ${roomId}`, error);
|
if (error.errcode === "M_LIMIT_EXCEEDED") {
|
||||||
|
await sleep(error.data.retry_after_ms);
|
||||||
|
await newClient.joinRoom(roomId);
|
||||||
|
} else {
|
||||||
|
captureException(error);
|
||||||
|
console.error(`Couldn't join room ${roomId}`, error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue