Skip to content

Commit

Permalink
Iterate
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Telatynski <[email protected]>
  • Loading branch information
t3chguy committed Oct 22, 2024
1 parent 028df70 commit 77e8469
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
12 changes: 8 additions & 4 deletions src/components/views/elements/PersistedElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,14 @@ export default class PersistedElement extends React.Component<IProps> {
</MatrixClientContext.Provider>
);

const container = getOrCreateContainer("mx_persistedElement_" + this.props.persistKey);
const root = createRoot(container);
PersistedElement.rootMap[this.props.persistKey] = [root, container];
root.render(content);
let rootPair = PersistedElement.rootMap[this.props.persistKey];
if (!rootPair) {
const container = getOrCreateContainer("mx_persistedElement_" + this.props.persistKey);
const root = createRoot(container);
rootPair = [root, container];
PersistedElement.rootMap[this.props.persistKey] = rootPair;
}
rootPair[0].render(content);
}

private updateChildVisibility(child?: HTMLDivElement, visible = false): void {
Expand Down
18 changes: 10 additions & 8 deletions test/unit-tests/components/structures/PipContainer-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,22 +163,24 @@ describe("PipContainer", () => {
if (!(call instanceof MockedCall)) throw new Error("Failed to create call");

const widget = new Widget(call.widget);
WidgetStore.instance.addVirtualWidget(call.widget, room.roomId);
WidgetMessagingStore.instance.storeMessaging(widget, room.roomId, {
stop: () => {},
} as unknown as ClientWidgetApi);

await act(async () => {
WidgetStore.instance.addVirtualWidget(call.widget, room.roomId);
WidgetMessagingStore.instance.storeMessaging(widget, room.roomId, {
stop: () => {},
} as unknown as ClientWidgetApi);

await call.start();
ActiveWidgetStore.instance.setWidgetPersistence(widget.id, room.roomId, true);
});

await fn(call);

cleanup();
call.destroy();
ActiveWidgetStore.instance.destroyPersistentWidget(widget.id, room.roomId);
WidgetStore.instance.removeVirtualWidget(widget.id, room.roomId);
act(() => {
call.destroy();
ActiveWidgetStore.instance.destroyPersistentWidget(widget.id, room.roomId);
WidgetStore.instance.removeVirtualWidget(widget.id, room.roomId);
});
};

const withWidget = async (fn: () => Promise<void>): Promise<void> => {
Expand Down

0 comments on commit 77e8469

Please sign in to comment.