sed on the event (e.g., new tab, // current tab) const where = lazy.BrowserUtils.whereToOpenLink(event, false, true); win.openLinkIn(url, where, params); this.dispatchEvent( new CustomEvent("LinkPreviewCard:dismiss", { detail: event.target.dataset.source ?? "error", }) ); } /** * Handles retry request for key points generation. * * @param {MouseEvent} event - The click event. */ handleRetry(event) { event.preventDefault(); // Dispatch retry event to be handled by LinkPreview.sys.mjs this.dispatchEvent(new CustomEvent("LinkPreviewCard:retry")); } /** * Toggles the expanded state of the key points section * * @param {MouseEvent} _event - The click event */ toggleKeyPoints(_event) { // Do not allow collapsing while a download is in progress. if (this.progress >= 0) { return; } Services.prefs.setBoolPref( "browser.ml.linkPreview.collapsed", !this.collapsed ); // When expanded, if there are existing key points, we won't trigger // another generation if (!this.collapsed) { this.dispatchEvent(new CustomEvent("LinkPreviewCard:generate")); } } updated(_properties) { if (this.optinRef.value) { this.optinRef.value.headingIcon = LinkPreviewCard.AI_ICON; } if (this.firstTimeModalRef.value) { this.firstTimeModalRef.value.headingIcon = LinkPreviewCard.AI_ICON; this.firstTimeModalRef.value.iconAtEnd = true; this.firstTimeModalRef.value.footerMessageL10nId = ""; if (this.progress >= 0) { this.firstTimeModalRef.value.isLoading = true; this.firstTimeModalRef.value.progressStatus = this.progress; } } } /** * Get the appropriate Fluent ID for the error message based on the error state. * * @returns {string} The Fluent ID for the error message. */ get errorMessageL10nId() { if (this.isMissingDataErrorState) { return "link-preview-generation-error-missing-data-v2"; } else if (this.generationError) { return "link-preview-generation-error-unexpected"; } return ""; } /** * Renders the error generation card for when we have a generation error. * * @returns {import('lit').TemplateResult} The error generation card HTML */ renderErrorGenerationCard() { // Only show the retry link if we have a generation error that's not a memory error const showRetryLink = this.generationError && this.generationError.name !== "NotEnoughMemoryError"; return html`
${description}
` : ""}