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

93 lines
2.3 KiB
JavaScript
Raw Normal View History

2020-08-05 22:08:55 +05:30
/*
Copyright 2020 Bruno Windels <bruno@windels.cloud>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import {UpdateAction} from "../UpdateAction.js";
import {ViewModel} from "../../../../ViewModel.js";
export class SimpleTile extends ViewModel {
constructor({entry}) {
super();
2019-03-09 00:34:56 +05:30
this._entry = entry;
}
// view model props for all subclasses
// hmmm, could also do instanceof ... ?
get shape() {
return null;
2019-03-09 00:34:56 +05:30
// "gap" | "message" | "image" | ... ?
}
// don't show display name / avatar
// probably only for MessageTiles of some sort?
get isContinuation() {
return false;
}
get hasDateSeparator() {
return false;
}
get internalId() {
return this._entry.asEventKey().toString();
}
get isPending() {
return this._entry.isPending;
}
// TilesCollection contract below
setUpdateEmit(emitUpdate) {
this.updateOptions({emitChange: paramName => emitUpdate(this, paramName)});
}
get upperEntry() {
return this._entry;
2019-03-09 00:34:56 +05:30
}
get lowerEntry() {
return this._entry;
2019-03-09 00:34:56 +05:30
}
compareEntry(entry) {
return this._entry.compare(entry);
2019-03-09 00:34:56 +05:30
}
// update received for already included (falls within sort keys) entry
updateEntry(entry) {
this._entry = entry;
return UpdateAction.Nothing();
2019-03-09 05:10:03 +05:30
}
2019-03-09 00:34:56 +05:30
2019-03-09 05:10:03 +05:30
// return whether the tile should be removed
// as SimpleTile only has one entry, the tile should be removed
removeEntry(entry) {
return true;
2019-03-09 00:34:56 +05:30
}
2019-03-09 05:10:03 +05:30
// SimpleTile can only contain 1 entry
2019-03-09 00:34:56 +05:30
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
2019-03-09 00:34:56 +05:30
}