better error handling in RoomBeingCreated
This commit is contained in:
parent
d6d1af13d0
commit
f12841b2d3
1 changed files with 49 additions and 47 deletions
|
@ -117,6 +117,7 @@ export class RoomBeingCreated extends EventEmitter<{change: never}> {
|
||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
async create(hsApi: HomeServerApi, log: ILogItem): Promise<void> {
|
async create(hsApi: HomeServerApi, log: ILogItem): Promise<void> {
|
||||||
|
try {
|
||||||
let avatarEventContent;
|
let avatarEventContent;
|
||||||
if (this.options.avatar) {
|
if (this.options.avatar) {
|
||||||
const {avatar} = this.options;
|
const {avatar} = this.options;
|
||||||
|
@ -154,7 +155,6 @@ export class RoomBeingCreated extends EventEmitter<{change: never}> {
|
||||||
content: avatarEventContent
|
content: avatarEventContent
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
const response = await hsApi.createRoom(createOptions, {log}).response();
|
const response = await hsApi.createRoom(createOptions, {log}).response();
|
||||||
this._roomId = response["room_id"];
|
this._roomId = response["room_id"];
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
@ -170,6 +170,7 @@ export class RoomBeingCreated extends EventEmitter<{change: never}> {
|
||||||
* is running. */
|
* is running. */
|
||||||
/** @internal */
|
/** @internal */
|
||||||
async loadProfiles(hsApi: HomeServerApi, log: ILogItem): Promise<void> {
|
async loadProfiles(hsApi: HomeServerApi, log: ILogItem): Promise<void> {
|
||||||
|
try {
|
||||||
// only load profiles if we need it for the room name and avatar
|
// only load profiles if we need it for the room name and avatar
|
||||||
if (!this.options.name && this.options.invites) {
|
if (!this.options.name && this.options.invites) {
|
||||||
this.profiles = await loadProfiles(this.options.invites, hsApi, log);
|
this.profiles = await loadProfiles(this.options.invites, hsApi, log);
|
||||||
|
@ -180,6 +181,7 @@ export class RoomBeingCreated extends EventEmitter<{change: never}> {
|
||||||
this._calculatedName = calculateRoomName(this.profiles, summaryData, log);
|
this._calculatedName = calculateRoomName(this.profiles, summaryData, log);
|
||||||
this.emitChange();
|
this.emitChange();
|
||||||
}
|
}
|
||||||
|
} catch (err) {} // swallow error, loading profiles is not essential
|
||||||
}
|
}
|
||||||
|
|
||||||
private emitChange(params?: string) {
|
private emitChange(params?: string) {
|
||||||
|
|
Reference in a new issue