context-menu: Fix strictNullChecks violations.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2021-03-31 15:53:02 -07:00
parent bdf7d1b813
commit ff3ea429d2

View File

@@ -13,7 +13,6 @@ export const contextMenu = (
const isText = props.selectionText !== "";
const isLink = props.linkURL !== "";
const linkURL = isLink ? new URL(props.linkURL) : undefined;
const isEmailAddress = isLink ? linkURL.protocol === "mailto:" : undefined;
const makeSuggestion = (suggestion: string) => ({
label: suggestion,
@@ -77,12 +76,16 @@ export const contextMenu = (
type: "separator",
},
{
label: isEmailAddress ? t.__("Copy Email Address") : t.__("Copy Link"),
label:
linkURL?.protocol === "mailto:"
? t.__("Copy Email Address")
: t.__("Copy Link"),
visible: isLink,
click(_item) {
clipboard.write({
bookmark: props.linkText,
text: isEmailAddress ? linkURL.pathname : props.linkURL,
text:
linkURL?.protocol === "mailto:" ? linkURL.pathname : props.linkURL,
});
},
},