This repository has been archived on 2022-08-19. You can view files and clone it, but cannot push or open issues or pull requests.
hydrogen-web/src/domain/session/room/timeline/tiles/SimpleTile.js
Bruno Windels 001dbefbcf stop using default exports
because it becomes hard to remember where you used them and where not
2020-04-20 21:26:39 +02:00

82 lines
1.7 KiB
JavaScript

import {UpdateAction} from "../UpdateAction.js";
export class SimpleTile {
constructor({entry}) {
this._entry = entry;
this._emitUpdate = null;
}
// view model props for all subclasses
// hmmm, could also do instanceof ... ?
get shape() {
return null;
// "gap" | "message" | "image" | ... ?
}
// don't show display name / avatar
// probably only for MessageTiles of some sort?
get isContinuation() {
return false;
}
get hasDateSeparator() {
return false;
}
emitUpdate(paramName) {
if (this._emitUpdate) {
this._emitUpdate(this, paramName);
}
}
get internalId() {
return this._entry.asEventKey().toString();
}
get isPending() {
return this._entry.isPending;
}
// TilesCollection contract below
setUpdateEmit(emitUpdate) {
this._emitUpdate = emitUpdate;
}
get upperEntry() {
return this._entry;
}
get lowerEntry() {
return this._entry;
}
compareEntry(entry) {
return this._entry.compare(entry);
}
// update received for already included (falls within sort keys) entry
updateEntry(entry) {
this._entry = entry;
return UpdateAction.Nothing();
}
// return whether the tile should be removed
// as SimpleTile only has one entry, the tile should be removed
removeEntry(entry) {
return true;
}
// SimpleTile can only contain 1 entry
tryIncludeEntry() {
return false;
}
// let item know it has a new sibling
updatePreviousSibling(prev) {
}
// let item know it has a new sibling
updateNextSibling(next) {
}
// TilesCollection contract above
}