mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
Reuse code from timeline view
This commit is contained in:
parent
89d6968139
commit
f01d5d95d9
@ -17,11 +17,7 @@ limitations under the License.
|
||||
import {renderStaticAvatar} from "../../../avatar";
|
||||
import {tag} from "../../../general/html";
|
||||
import {TemplateView} from "../../../general/TemplateView";
|
||||
import {FileView} from "./FileView";
|
||||
import {ImageView} from "./ImageView";
|
||||
import {RedactedView} from "./RedactedView";
|
||||
import {TextMessageView} from "./TextMessageView.js";
|
||||
import {VideoView} from "./VideoView";
|
||||
import {viewClassForEntry} from "../TimelineView";
|
||||
|
||||
export class ReplyPreviewView extends TemplateView {
|
||||
render(t, vm) {
|
||||
@ -29,7 +25,9 @@ export class ReplyPreviewView extends TemplateView {
|
||||
}
|
||||
|
||||
_renderReplyPreview(t, vm) {
|
||||
const view = this._viewFromViewModel(vm);
|
||||
// todo: this should probably be called viewClassForTile instead
|
||||
const viewClass = viewClassForEntry(vm);
|
||||
const view = new viewClass(vm)
|
||||
const rendered = this._renderContent(t, vm, view);
|
||||
return this._renderReplyHeader(vm, [rendered]);
|
||||
}
|
||||
@ -44,24 +42,6 @@ export class ReplyPreviewView extends TemplateView {
|
||||
}
|
||||
}
|
||||
|
||||
_viewFromViewModel(vm) {
|
||||
if (vm.isRedacted) {
|
||||
return new RedactedView(vm);
|
||||
}
|
||||
const shape = vm.shape;
|
||||
switch (shape) {
|
||||
case "image":
|
||||
return new ImageView(vm);
|
||||
case "video":
|
||||
return new VideoView(vm);
|
||||
case "file":
|
||||
return new FileView(vm);
|
||||
case "message":
|
||||
case "message-status":
|
||||
return new TextMessageView(vm);
|
||||
}
|
||||
}
|
||||
|
||||
_renderReplyHeader(vm, children = []) {
|
||||
return tag.blockquote(
|
||||
[
|
||||
|
Loading…
Reference in New Issue
Block a user