Rename and document what local echo is

pull/21833/head
Travis Ralston 2020-07-30 09:15:19 -06:00
parent e3765ea8c5
commit fca6def588
5 changed files with 15 additions and 15 deletions

View File

@ -49,8 +49,8 @@ import { RoomNotificationStateStore } from "../../../stores/notifications/RoomNo
import { NOTIFICATION_STATE_UPDATE, NotificationState } from "../../../stores/notifications/NotificationState"; import { NOTIFICATION_STATE_UPDATE, NotificationState } from "../../../stores/notifications/NotificationState";
import AccessibleTooltipButton from "../elements/AccessibleTooltipButton"; import AccessibleTooltipButton from "../elements/AccessibleTooltipButton";
import { EchoChamber } from "../../../stores/local-echo/EchoChamber"; import { EchoChamber } from "../../../stores/local-echo/EchoChamber";
import { CachedRoomKey, RoomCachedEcho } from "../../../stores/local-echo/RoomCachedEcho"; import { CachedRoomKey, RoomEchoChamber } from "../../../stores/local-echo/RoomEchoChamber";
import { PROPERTY_UPDATED } from "../../../stores/local-echo/CachedEcho"; import { PROPERTY_UPDATED } from "../../../stores/local-echo/GenericEchoChamber";
interface IProps { interface IProps {
room: Room; room: Room;
@ -108,7 +108,7 @@ export default class RoomTile extends React.PureComponent<IProps, IState> {
private dispatcherRef: string; private dispatcherRef: string;
private roomTileRef = createRef<HTMLDivElement>(); private roomTileRef = createRef<HTMLDivElement>();
private notificationState: NotificationState; private notificationState: NotificationState;
private roomProps: RoomCachedEcho; private roomProps: RoomEchoChamber;
constructor(props: IProps) { constructor(props: IProps) {
super(props); super(props);

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import { RoomCachedEcho } from "./RoomCachedEcho"; import { RoomEchoChamber } from "./RoomEchoChamber";
import { Room } from "matrix-js-sdk/src/models/room"; import { Room } from "matrix-js-sdk/src/models/room";
import { EchoStore } from "./EchoStore"; import { EchoStore } from "./EchoStore";
@ -25,7 +25,7 @@ export class EchoChamber {
private constructor() { private constructor() {
} }
public static forRoom(room: Room): RoomCachedEcho { public static forRoom(room: Room): RoomEchoChamber {
return EchoStore.instance.getOrCreateEchoForRoom(room); return EchoStore.instance.getOrCreateChamberForRoom(room);
} }
} }

View File

@ -14,9 +14,9 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import { CachedEcho } from "./CachedEcho"; import { GenericEchoChamber } from "./GenericEchoChamber";
import { Room } from "matrix-js-sdk/src/models/room"; import { Room } from "matrix-js-sdk/src/models/room";
import { RoomCachedEcho } from "./RoomCachedEcho"; import { RoomEchoChamber } from "./RoomEchoChamber";
import { RoomEchoContext } from "./RoomEchoContext"; import { RoomEchoContext } from "./RoomEchoContext";
import { AsyncStoreWithClient } from "../AsyncStoreWithClient"; import { AsyncStoreWithClient } from "../AsyncStoreWithClient";
import defaultDispatcher from "../../dispatcher/dispatcher"; import defaultDispatcher from "../../dispatcher/dispatcher";
@ -36,7 +36,7 @@ const roomContextKey = (room: Room): ContextKey => `room-${room.roomId}`;
export class EchoStore extends AsyncStoreWithClient<IState> { export class EchoStore extends AsyncStoreWithClient<IState> {
private static _instance: EchoStore; private static _instance: EchoStore;
private caches = new Map<ContextKey, CachedEcho<any, any, any>>(); private caches = new Map<ContextKey, GenericEchoChamber<any, any, any>>();
constructor() { constructor() {
super(defaultDispatcher); super(defaultDispatcher);
@ -53,15 +53,15 @@ export class EchoStore extends AsyncStoreWithClient<IState> {
return Array.from(this.caches.values()).map(e => e.context); return Array.from(this.caches.values()).map(e => e.context);
} }
public getOrCreateEchoForRoom(room: Room): RoomCachedEcho { public getOrCreateChamberForRoom(room: Room): RoomEchoChamber {
if (this.caches.has(roomContextKey(room))) { if (this.caches.has(roomContextKey(room))) {
return this.caches.get(roomContextKey(room)) as RoomCachedEcho; return this.caches.get(roomContextKey(room)) as RoomEchoChamber;
} }
const context = new RoomEchoContext(room); const context = new RoomEchoContext(room);
context.whenAnything(() => this.checkContexts()); context.whenAnything(() => this.checkContexts());
const echo = new RoomCachedEcho(context); const echo = new RoomEchoChamber(context);
echo.setClient(this.matrixClient); echo.setClient(this.matrixClient);
this.caches.set(roomContextKey(room), echo); this.caches.set(roomContextKey(room), echo);

View File

@ -25,7 +25,7 @@ export async function implicitlyReverted() {
export const PROPERTY_UPDATED = "property_updated"; export const PROPERTY_UPDATED = "property_updated";
export abstract class CachedEcho<C extends EchoContext, K, V> extends EventEmitter { export abstract class GenericEchoChamber<C extends EchoContext, K, V> extends EventEmitter {
private cache = new Map<K, {txn: EchoTransaction, val: V}>(); private cache = new Map<K, {txn: EchoTransaction, val: V}>();
protected matrixClient: MatrixClient; protected matrixClient: MatrixClient;

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import { CachedEcho, implicitlyReverted, PROPERTY_UPDATED } from "./CachedEcho"; import { GenericEchoChamber, implicitlyReverted, PROPERTY_UPDATED } from "./GenericEchoChamber";
import { getRoomNotifsState, setRoomNotifsState } from "../../RoomNotifs"; import { getRoomNotifsState, setRoomNotifsState } from "../../RoomNotifs";
import { RoomEchoContext } from "./RoomEchoContext"; import { RoomEchoContext } from "./RoomEchoContext";
import { _t } from "../../languageHandler"; import { _t } from "../../languageHandler";
@ -27,7 +27,7 @@ export enum CachedRoomKey {
NotificationVolume, NotificationVolume,
} }
export class RoomCachedEcho extends CachedEcho<RoomEchoContext, CachedRoomKey, CachedRoomValues> { export class RoomEchoChamber extends GenericEchoChamber<RoomEchoContext, CachedRoomKey, CachedRoomValues> {
private properties = new Map<CachedRoomKey, CachedRoomValues>(); private properties = new Map<CachedRoomKey, CachedRoomValues>();
public constructor(context: RoomEchoContext) { public constructor(context: RoomEchoContext) {