pass features to tilesCreator (and all options really for comfort)

This commit is contained in:
Bruno Windels 2023-02-09 11:56:22 +01:00
parent d5929d9ebe
commit f86663fe7b
4 changed files with 4 additions and 4 deletions

View File

@ -209,7 +209,7 @@ export class RoomViewModel extends ErrorReportViewModel {
_createTile(entry) { _createTile(entry) {
if (this._tileOptions) { if (this._tileOptions) {
const Tile = this._tileOptions.tileClassForEntry(entry); const Tile = this._tileOptions.tileClassForEntry(entry, this._tileOptions);
if (Tile) { if (Tile) {
return new Tile(entry, this._tileOptions); return new Tile(entry, this._tileOptions);
} }

View File

@ -34,7 +34,7 @@ export class TilesCollection extends BaseObservableList {
} }
_createTile(entry) { _createTile(entry) {
const Tile = this._tileOptions.tileClassForEntry(entry); const Tile = this._tileOptions.tileClassForEntry(entry, this._tileOptions);
if (Tile) { if (Tile) {
return new Tile(entry, this._tileOptions); return new Tile(entry, this._tileOptions);
} }

View File

@ -126,7 +126,7 @@ export class BaseMessageTile extends SimpleTile {
if (action?.shouldReplace || !this._replyTile) { if (action?.shouldReplace || !this._replyTile) {
this.disposeTracked(this._replyTile); this.disposeTracked(this._replyTile);
const tileClassForEntry = this._options.tileClassForEntry; const tileClassForEntry = this._options.tileClassForEntry;
const ReplyTile = tileClassForEntry(replyEntry); const ReplyTile = tileClassForEntry(replyEntry, this._options);
if (ReplyTile) { if (ReplyTile) {
this._replyTile = new ReplyTile(replyEntry, this._options); this._replyTile = new ReplyTile(replyEntry, this._options);
} }

View File

@ -47,7 +47,7 @@ export type Options = ViewModelOptions & {
}; };
export type TileConstructor = new (entry: TimelineEntry, options: Options) => ITile; export type TileConstructor = new (entry: TimelineEntry, options: Options) => ITile;
export function tileClassForEntry(entry: TimelineEntry): TileConstructor | undefined { export function tileClassForEntry(entry: TimelineEntry, options: Options): TileConstructor | undefined {
if (entry.isGap) { if (entry.isGap) {
return GapTile; return GapTile;
} else if (entry.isPending && entry.pendingEvent.isMissingAttachments) { } else if (entry.isPending && entry.pendingEvent.isMissingAttachments) {