91a3cb03c1
mkdir apps/web/scripts
mv scripts/{cleanup.sh,ci_package.sh,copy-res.ts,deploy.py,package.sh} apps/web/scripts
And a couple of gitignore tweaks
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
/*
|
|
Copyright 2025 Element Creations Ltd.
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
|
Please see LICENSE files in the repository root for full details.
|
|
*/
|
|
|
|
import { type Room as IRoom, Watchable } from "@element-hq/element-web-module-api";
|
|
import { RoomEvent, type Room as SdkRoom } from "matrix-js-sdk/src/matrix";
|
|
|
|
export class Room implements IRoom {
|
|
public name: Watchable<string>;
|
|
|
|
public constructor(private sdkRoom: SdkRoom) {
|
|
this.name = new WatchableName(sdkRoom);
|
|
}
|
|
|
|
public getLastActiveTimestamp(): number {
|
|
return this.sdkRoom.getLastActiveTimestamp();
|
|
}
|
|
|
|
public get id(): string {
|
|
return this.sdkRoom.roomId;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* A custom watchable for room name.
|
|
*/
|
|
class WatchableName extends Watchable<string> {
|
|
public constructor(private sdkRoom: SdkRoom) {
|
|
super(sdkRoom.name);
|
|
}
|
|
|
|
private onNameUpdate = (): void => {
|
|
super.value = this.sdkRoom.name;
|
|
};
|
|
protected onFirstWatch(): void {
|
|
this.sdkRoom.on(RoomEvent.Name, this.onNameUpdate);
|
|
}
|
|
|
|
protected onLastWatch(): void {
|
|
this.sdkRoom.off(RoomEvent.Name, this.onNameUpdate);
|
|
}
|
|
}
|