From 2d8000d11dad598cf9268e5087e29b576c88e4cf Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 10 Nov 2020 17:50:53 +0100 Subject: [PATCH] file tile view --- .../session/room/timeline/tilesCreator.js | 3 ++ .../web/ui/session/room/TimelineList.js | 2 ++ .../web/ui/session/room/timeline/FileView.js | 29 +++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 src/platform/web/ui/session/room/timeline/FileView.js diff --git a/src/domain/session/room/timeline/tilesCreator.js b/src/domain/session/room/timeline/tilesCreator.js index 549ad65d..9ac27a54 100644 --- a/src/domain/session/room/timeline/tilesCreator.js +++ b/src/domain/session/room/timeline/tilesCreator.js @@ -17,6 +17,7 @@ limitations under the License. import {GapTile} from "./tiles/GapTile.js"; import {TextTile} from "./tiles/TextTile.js"; import {ImageTile} from "./tiles/ImageTile.js"; +import {FileTile} from "./tiles/FileTile.js"; import {LocationTile} from "./tiles/LocationTile.js"; import {RoomNameTile} from "./tiles/RoomNameTile.js"; import {RoomMemberTile} from "./tiles/RoomMemberTile.js"; @@ -40,6 +41,8 @@ export function tilesCreator(baseOptions) { return new TextTile(options); case "m.image": return new ImageTile(options); + case "m.file": + return new FileTile(options); case "m.location": return new LocationTile(options); default: diff --git a/src/platform/web/ui/session/room/TimelineList.js b/src/platform/web/ui/session/room/TimelineList.js index 0cadbb71..5d0f3fbe 100644 --- a/src/platform/web/ui/session/room/TimelineList.js +++ b/src/platform/web/ui/session/room/TimelineList.js @@ -18,6 +18,7 @@ import {ListView} from "../../general/ListView.js"; import {GapView} from "./timeline/GapView.js"; import {TextMessageView} from "./timeline/TextMessageView.js"; import {ImageView} from "./timeline/ImageView.js"; +import {FileView} from "./timeline/FileView.js"; import {AnnouncementView} from "./timeline/AnnouncementView.js"; function viewClassForEntry(entry) { @@ -28,6 +29,7 @@ function viewClassForEntry(entry) { case "message-status": return TextMessageView; case "image": return ImageView; + case "file": return FileView; } } diff --git a/src/platform/web/ui/session/room/timeline/FileView.js b/src/platform/web/ui/session/room/timeline/FileView.js new file mode 100644 index 00000000..cb99dd0a --- /dev/null +++ b/src/platform/web/ui/session/room/timeline/FileView.js @@ -0,0 +1,29 @@ +/* +Copyright 2020 Bruno Windels + +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 {TemplateView} from "../../../general/TemplateView.js"; +import {renderMessage} from "./common.js"; + +export class FileView extends TemplateView { + render(t, vm) { + return renderMessage(t, vm, [ + t.p([ + t.button({className: "link", onClick: () => vm.download()}, vm => vm.label), + t.time({className: {hidden: !vm.date}}, vm.date + " " + vm.time) + ]) + ]); + } +}