Skip to content

Commit 238cb01

Browse files
committed
Use hook in TextualEventFactory
1 parent b3f8ee4 commit 238cb01

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/events/EventTileFactory.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import ModuleApi from "../modules/Api";
4545
import { TextualEventViewModel } from "../viewmodels/event-tiles/TextualEventViewModel";
4646
import { TextualEventView } from "../shared-components/event-tiles/TextualEventView";
4747
import { ElementCallEventType } from "../call-types";
48+
import { useAutoDisposedViewModel } from "../viewmodels/base/useAutoDisposedViewModel";
4849

4950
// Subset of EventTile's IProps plus some mixins
5051
export interface EventTileTypeProps
@@ -79,10 +80,15 @@ const LegacyCallEventFactory: Factory<FactoryProps & { callEventGrouper: LegacyC
7980
<LegacyCallEvent ref={ref} {...props} />
8081
);
8182
const CallEventFactory: Factory = (ref, props) => <CallEvent ref={ref} {...props} />;
82-
export const TextualEventFactory: Factory = (ref, props) => {
83-
const vm = new TextualEventViewModel(props);
83+
84+
const TextualEventComponent: React.FC<FactoryProps> = (props) => {
85+
const vm = useAutoDisposedViewModel(() => new TextualEventViewModel(props));
8486
return <TextualEventView vm={vm} />;
8587
};
88+
export const TextualEventFactory: Factory = (ref, props) => {
89+
return <TextualEventComponent {...props} />;
90+
};
91+
8692
const VerificationReqFactory: Factory = (_ref, props) => <MKeyVerificationRequest {...props} />;
8793
const HiddenEventFactory: Factory = (ref, props) => <HiddenBody ref={ref} {...props} />;
8894

0 commit comments

Comments
 (0)