diff --git a/src/domain/session/CreateRoomViewModel.js b/src/domain/session/CreateRoomViewModel.js index 47656128..b398b615 100644 --- a/src/domain/session/CreateRoomViewModel.js +++ b/src/domain/session/CreateRoomViewModel.js @@ -82,7 +82,7 @@ export class CreateRoomViewModel extends ViewModel { avatar, invites: ["@bwindels:matrix.org"] }); - this.navigation.push("room", roomBeingCreated.localId); + this.navigation.push("room", roomBeingCreated.id); } diff --git a/src/domain/session/leftpanel/RoomBeingCreatedTileViewModel.js b/src/domain/session/leftpanel/RoomBeingCreatedTileViewModel.js index d7840bfa..c80fba6c 100644 --- a/src/domain/session/leftpanel/RoomBeingCreatedTileViewModel.js +++ b/src/domain/session/leftpanel/RoomBeingCreatedTileViewModel.js @@ -22,7 +22,7 @@ export class RoomBeingCreatedTileViewModel extends BaseTileViewModel { super(options); const {roomBeingCreated} = options; this._roomBeingCreated = roomBeingCreated; - this._url = this.urlCreator.openRoomActionUrl(this._roomBeingCreated.localId); + this._url = this.urlCreator.openRoomActionUrl(this._roomBeingCreated.id); } get busy() { return true; } diff --git a/src/domain/session/rightpanel/MemberDetailsViewModel.js b/src/domain/session/rightpanel/MemberDetailsViewModel.js index 68045eba..f5169afa 100644 --- a/src/domain/session/rightpanel/MemberDetailsViewModel.js +++ b/src/domain/session/rightpanel/MemberDetailsViewModel.js @@ -90,7 +90,7 @@ export class MemberDetailsViewModel extends ViewModel { type: RoomType.DirectMessage, invites: [this.userId] }); - roomId = roomBeingCreated.localId; + roomId = roomBeingCreated.id; } this.navigation.push("room", roomId); } diff --git a/src/domain/session/room/RoomBeingCreatedViewModel.js b/src/domain/session/room/RoomBeingCreatedViewModel.js index eebbb668..e9cb3616 100644 --- a/src/domain/session/room/RoomBeingCreatedViewModel.js +++ b/src/domain/session/room/RoomBeingCreatedViewModel.js @@ -32,7 +32,7 @@ export class RoomBeingCreatedViewModel extends ViewModel { get kind() { return "roomBeingCreated"; } get closeUrl() { return this._closeUrl; } get name() { return this._roomBeingCreated.name; } - get id() { return this._roomBeingCreated.localId; } + get id() { return this._roomBeingCreated.id; } get isEncrypted() { return this._roomBeingCreated.isEncrypted; } get avatarLetter() { diff --git a/src/matrix/Session.js b/src/matrix/Session.js index b03306ed..2d4516ea 100644 --- a/src/matrix/Session.js +++ b/src/matrix/Session.js @@ -64,7 +64,13 @@ export class Session { this._activeArchivedRooms = new Map(); this._invites = new ObservableMap(); this._inviteUpdateCallback = (invite, params) => this._invites.update(invite.id, params); - this._roomsBeingCreatedUpdateCallback = (rbc, params) => this._roomsBeingCreated.update(rbc.localId, params); + this._roomsBeingCreatedUpdateCallback = (rbc, params) => { + if (rbc.isCancelled) { + this._roomsBeingCreated.remove(rbc.id); + } else { + this._roomsBeingCreated.update(rbc.id, params) + } + }; this._roomsBeingCreated = new ObservableMap(); this._user = new User(sessionInfo.userId); this._deviceMessageHandler = new DeviceMessageHandler({storage}); @@ -603,11 +609,11 @@ export class Session { createRoom(options, log = undefined) { let roomBeingCreated; this._platform.logger.runDetached("create room", async log => { - const localId = `local-${Math.floor(this._platform.random() * Number.MAX_SAFE_INTEGER)}`; + const id = `local-${Math.floor(this._platform.random() * Number.MAX_SAFE_INTEGER)}`; roomBeingCreated = new RoomBeingCreated( - localId, options, this._roomsBeingCreatedUpdateCallback, + id, options, this._roomsBeingCreatedUpdateCallback, this._mediaRepository, this._platform, log); - this._roomsBeingCreated.set(localId, roomBeingCreated); + this._roomsBeingCreated.set(id, roomBeingCreated); const promises = [roomBeingCreated.create(this._hsApi, log)]; const loadProfiles = !(options.loadProfiles === false); // default to true if (loadProfiles) { @@ -709,15 +715,15 @@ export class Session { _tryReplaceRoomBeingCreated(roomId, log) { for (const [,roomBeingCreated] of this._roomsBeingCreated) { if (roomBeingCreated.roomId === roomId) { - const observableStatus = this._observedRoomStatus.get(roomBeingCreated.localId); + const observableStatus = this._observedRoomStatus.get(roomBeingCreated.id); if (observableStatus) { log.log(`replacing room being created`) - .set("localId", roomBeingCreated.localId) + .set("localId", roomBeingCreated.id) .set("roomId", roomBeingCreated.roomId); observableStatus.set(observableStatus.get() | RoomStatus.Replaced); } roomBeingCreated.dispose(); - this._roomsBeingCreated.remove(roomBeingCreated.localId); + this._roomsBeingCreated.remove(roomBeingCreated.id); return; } } diff --git a/src/matrix/room/create.ts b/src/matrix/room/create.ts index 6dd9340a..cc65892e 100644 --- a/src/matrix/room/create.ts +++ b/src/matrix/room/create.ts @@ -94,7 +94,7 @@ export class RoomBeingCreated extends EventEmitter<{change: never}> { private _error?: Error; constructor( - public readonly localId: string, + public readonly id: string, private readonly options: Options, private readonly updateCallback: (self: RoomBeingCreated, params: string | undefined) => void, public readonly mediaRepository: MediaRepository, @@ -187,15 +187,13 @@ export class RoomBeingCreated extends EventEmitter<{change: never}> { this.emit("change"); } - get avatarColorId(): string { return this.options.invites?.[0] ?? this._roomId ?? this.localId; } get avatarUrl(): string | undefined { return this.profiles?.[0].avatarUrl; } + get avatarColorId(): string { return this.options.invites?.[0] ?? this._roomId ?? this.id; } get avatarBlobUrl(): string | undefined { return this.options.avatar?.blob?.url; } get roomId(): string | undefined { return this._roomId; } get name() { return this._calculatedName; } get isBeingCreated(): boolean { return true; } get error(): Error | undefined { return this._error; } - get id() { return this.localId; } - cancel() { // TODO: remove from collection somehow }