rename RoomBeingCreated.localId to id

This commit is contained in:
Bruno Windels 2022-02-10 11:03:52 +01:00
parent bbb1683dbf
commit d6d1af13d0
6 changed files with 19 additions and 15 deletions

View File

@ -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);
}

View File

@ -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; }

View File

@ -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);
}

View File

@ -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() {

View File

@ -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;
}
}

View File

@ -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
}