Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Hide URL preview if it will be empty #9029

Merged
merged 5 commits into from
Jul 7, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/components/views/rooms/LinkPreviewWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ export default class LinkPreviewWidget extends React.Component<IProps> {
</div>;
}

// Don't show anything if we're about to render nothing
if (!img && !p["og:description"] && !p["og:title"]) {
return null;
}

// The description includes &-encoded HTML entities, we decode those as React treats the thing as an
// opaque string. This does not allow any HTML to be injected into the DOM.
const description = AllHtmlEntities.decode(p["og:description"] || "");
Expand Down