2021-12-17 16:22:45 +05:30
|
|
|
/*
|
|
|
|
Copyright 2021 The Matrix.org Foundation C.I.C.
|
|
|
|
|
|
|
|
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 {TextMessageView} from "./timeline/TextMessageView.js";
|
|
|
|
import {ImageView} from "./timeline/ImageView.js";
|
|
|
|
import {VideoView} from "./timeline/VideoView.js";
|
|
|
|
import {FileView} from "./timeline/FileView.js";
|
2022-01-14 20:13:24 +05:30
|
|
|
import {LocationView} from "./timeline/LocationView.js";
|
2021-12-17 16:22:45 +05:30
|
|
|
import {MissingAttachmentView} from "./timeline/MissingAttachmentView.js";
|
|
|
|
import {AnnouncementView} from "./timeline/AnnouncementView.js";
|
|
|
|
import {RedactedView} from "./timeline/RedactedView.js";
|
|
|
|
import {SimpleTile} from "../../../../../domain/session/room/timeline/tiles/SimpleTile.js";
|
|
|
|
import {GapView} from "./timeline/GapView.js";
|
2022-04-07 20:49:43 +05:30
|
|
|
import type {TileViewConstructor, ViewClassForEntryFn} from "./TimelineView";
|
2022-01-14 20:17:22 +05:30
|
|
|
|
2022-04-07 20:49:43 +05:30
|
|
|
export function viewClassForEntry(vm: SimpleTile): TileViewConstructor {
|
|
|
|
switch (vm.shape) {
|
2022-01-06 22:07:17 +05:30
|
|
|
case "gap":
|
|
|
|
return GapView;
|
|
|
|
case "announcement":
|
|
|
|
return AnnouncementView;
|
2021-12-17 16:22:45 +05:30
|
|
|
case "message":
|
|
|
|
case "message-status":
|
|
|
|
return TextMessageView;
|
2022-01-06 22:07:17 +05:30
|
|
|
case "image":
|
|
|
|
return ImageView;
|
|
|
|
case "video":
|
|
|
|
return VideoView;
|
|
|
|
case "file":
|
|
|
|
return FileView;
|
2022-01-14 20:13:24 +05:30
|
|
|
case "location":
|
|
|
|
return LocationView;
|
2022-01-06 22:07:17 +05:30
|
|
|
case "missing-attachment":
|
|
|
|
return MissingAttachmentView;
|
2021-12-17 16:22:45 +05:30
|
|
|
case "redacted":
|
|
|
|
return RedactedView;
|
2022-04-07 20:49:43 +05:30
|
|
|
default:
|
2022-04-08 16:22:30 +05:30
|
|
|
throw new Error(`Tiles of shape "${vm.shape}" are not supported, check the tileClassForEntry function in the view model`);
|
2021-12-17 16:22:45 +05:30
|
|
|
}
|
|
|
|
}
|