From 463ec48a8d638e7ab5a17b630234e758ea28b8ca Mon Sep 17 00:00:00 2001 From: Lim Chee Aun <cheeaun@gmail.com> Date: Sat, 7 Sep 2024 15:26:57 +0800 Subject: [PATCH] Fix "overload resolution failed" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit convertToBlob returns promise š«£ --- src/components/status.jsx | 18 ++++++++----- src/locales/en.po | 54 +++++++++++++++++++-------------------- 2 files changed, 39 insertions(+), 33 deletions(-) diff --git a/src/components/status.jsx b/src/components/status.jsx index da0d0543..a337cfde 100644 --- a/src/components/status.jsx +++ b/src/components/status.jsx @@ -2641,9 +2641,9 @@ function Card({ card, selfReferential, instance }) { [hasIframeHTML], ); + const [blurhashImage, setBlurhashImage] = useState(null); if (hasText && (image || (type === 'photo' && blurhash))) { const domain = getDomain(url); - let blurhashImage; const rgbAverageColor = image && blurhash ? getBlurHashAverageColor(blurhash) : null; if (!image) { @@ -2660,11 +2660,17 @@ function Card({ card, selfReferential, instance }) { const imageData = ctx.createImageData(w, h); imageData.data.set(blurhashPixels); ctx.putImageData(imageData, 0, 0); - if (window.OffscreenCanvas) { - const blob = canvas.convertToBlob(); - blurhashImage = URL.createObjectURL(blob); - } else { - blurhashImage = canvas.toDataURL(); + try { + if (window.OffscreenCanvas) { + canvas.convertToBlob().then((blob) => { + setBlurhashImage(URL.createObjectURL(blob)); + }); + } else { + setBlurhashImage(canvas.toDataURL()); + } + } catch (e) { + // Silently fail + console.error(e); } } diff --git a/src/locales/en.po b/src/locales/en.po index c98c4b30..9b9155f2 100644 --- a/src/locales/en.po +++ b/src/locales/en.po @@ -289,7 +289,7 @@ msgstr "" #: src/components/account-info.jsx:1308 #: src/components/shortcuts-settings.jsx:1056 #: src/components/status.jsx:1088 -#: src/components/status.jsx:3115 +#: src/components/status.jsx:3121 msgid "Copy" msgstr "" @@ -417,9 +417,9 @@ msgstr "" #: src/components/shortcuts-settings.jsx:227 #: src/components/shortcuts-settings.jsx:580 #: src/components/shortcuts-settings.jsx:780 -#: src/components/status.jsx:2840 -#: src/components/status.jsx:3079 -#: src/components/status.jsx:3577 +#: src/components/status.jsx:2846 +#: src/components/status.jsx:3085 +#: src/components/status.jsx:3583 #: src/pages/accounts.jsx:36 #: src/pages/catchup.jsx:1564 #: src/pages/filters.jsx:224 @@ -1207,9 +1207,9 @@ msgid "Filtered: {filterTitleStr}" msgstr "" #: src/components/media-post.jsx:133 -#: src/components/status.jsx:3407 -#: src/components/status.jsx:3503 -#: src/components/status.jsx:3581 +#: src/components/status.jsx:3413 +#: src/components/status.jsx:3509 +#: src/components/status.jsx:3587 #: src/components/timeline.jsx:971 #: src/pages/catchup.jsx:75 #: src/pages/catchup.jsx:1859 @@ -2094,7 +2094,7 @@ msgid "Edited: {editedDateText}" msgstr "" #: src/components/status.jsx:1123 -#: src/components/status.jsx:3084 +#: src/components/status.jsx:3090 msgid "Embed post" msgstr "" @@ -2218,76 +2218,76 @@ msgstr "" msgid "Comments" msgstr "" -#: src/components/status.jsx:2845 +#: src/components/status.jsx:2851 msgid "Edit History" msgstr "" -#: src/components/status.jsx:2849 +#: src/components/status.jsx:2855 msgid "Failed to load history" msgstr "" -#: src/components/status.jsx:2854 +#: src/components/status.jsx:2860 msgid "Loadingā¦" msgstr "" -#: src/components/status.jsx:3089 +#: src/components/status.jsx:3095 msgid "HTML Code" msgstr "" -#: src/components/status.jsx:3106 +#: src/components/status.jsx:3112 msgid "HTML code copied" msgstr "" -#: src/components/status.jsx:3109 +#: src/components/status.jsx:3115 msgid "Unable to copy HTML code" msgstr "" -#: src/components/status.jsx:3121 +#: src/components/status.jsx:3127 msgid "Media attachments:" msgstr "" -#: src/components/status.jsx:3143 +#: src/components/status.jsx:3149 msgid "Account Emojis:" msgstr "" -#: src/components/status.jsx:3174 -#: src/components/status.jsx:3219 +#: src/components/status.jsx:3180 +#: src/components/status.jsx:3225 msgid "static URL" msgstr "" -#: src/components/status.jsx:3188 +#: src/components/status.jsx:3194 msgid "Emojis:" msgstr "" -#: src/components/status.jsx:3233 +#: src/components/status.jsx:3239 msgid "Notes:" msgstr "" -#: src/components/status.jsx:3237 +#: src/components/status.jsx:3243 msgid "This is static, unstyled and scriptless. You may need to apply your own styles and edit as needed." msgstr "" -#: src/components/status.jsx:3243 +#: src/components/status.jsx:3249 msgid "Polls are not interactive, becomes a list with vote counts." msgstr "" -#: src/components/status.jsx:3248 +#: src/components/status.jsx:3254 msgid "Media attachments can be images, videos, audios or any file types." msgstr "" -#: src/components/status.jsx:3254 +#: src/components/status.jsx:3260 msgid "Post could be edited or deleted later." msgstr "" -#: src/components/status.jsx:3260 +#: src/components/status.jsx:3266 msgid "Preview" msgstr "" -#: src/components/status.jsx:3269 +#: src/components/status.jsx:3275 msgid "Note: This preview is lightly styled." msgstr "" -#: src/components/status.jsx:3511 +#: src/components/status.jsx:3517 msgid "<0/> <1/> boosted" msgstr ""