Fix "overload resolution failed"

convertToBlob returns promise 🫣
This commit is contained in:
Lim Chee Aun 2024-09-07 15:26:57 +08:00
parent 036d3c8d83
commit 463ec48a8d
2 changed files with 39 additions and 33 deletions

View file

@ -2641,9 +2641,9 @@ function Card({ card, selfReferential, instance }) {
[hasIframeHTML], [hasIframeHTML],
); );
const [blurhashImage, setBlurhashImage] = useState(null);
if (hasText && (image || (type === 'photo' && blurhash))) { if (hasText && (image || (type === 'photo' && blurhash))) {
const domain = getDomain(url); const domain = getDomain(url);
let blurhashImage;
const rgbAverageColor = const rgbAverageColor =
image && blurhash ? getBlurHashAverageColor(blurhash) : null; image && blurhash ? getBlurHashAverageColor(blurhash) : null;
if (!image) { if (!image) {
@ -2660,11 +2660,17 @@ function Card({ card, selfReferential, instance }) {
const imageData = ctx.createImageData(w, h); const imageData = ctx.createImageData(w, h);
imageData.data.set(blurhashPixels); imageData.data.set(blurhashPixels);
ctx.putImageData(imageData, 0, 0); ctx.putImageData(imageData, 0, 0);
if (window.OffscreenCanvas) { try {
const blob = canvas.convertToBlob(); if (window.OffscreenCanvas) {
blurhashImage = URL.createObjectURL(blob); canvas.convertToBlob().then((blob) => {
} else { setBlurhashImage(URL.createObjectURL(blob));
blurhashImage = canvas.toDataURL(); });
} else {
setBlurhashImage(canvas.toDataURL());
}
} catch (e) {
// Silently fail
console.error(e);
} }
} }

54
src/locales/en.po generated
View file

@ -289,7 +289,7 @@ msgstr ""
#: src/components/account-info.jsx:1308 #: src/components/account-info.jsx:1308
#: src/components/shortcuts-settings.jsx:1056 #: src/components/shortcuts-settings.jsx:1056
#: src/components/status.jsx:1088 #: src/components/status.jsx:1088
#: src/components/status.jsx:3115 #: src/components/status.jsx:3121
msgid "Copy" msgid "Copy"
msgstr "" msgstr ""
@ -417,9 +417,9 @@ msgstr ""
#: src/components/shortcuts-settings.jsx:227 #: src/components/shortcuts-settings.jsx:227
#: src/components/shortcuts-settings.jsx:580 #: src/components/shortcuts-settings.jsx:580
#: src/components/shortcuts-settings.jsx:780 #: src/components/shortcuts-settings.jsx:780
#: src/components/status.jsx:2840 #: src/components/status.jsx:2846
#: src/components/status.jsx:3079 #: src/components/status.jsx:3085
#: src/components/status.jsx:3577 #: src/components/status.jsx:3583
#: src/pages/accounts.jsx:36 #: src/pages/accounts.jsx:36
#: src/pages/catchup.jsx:1564 #: src/pages/catchup.jsx:1564
#: src/pages/filters.jsx:224 #: src/pages/filters.jsx:224
@ -1207,9 +1207,9 @@ msgid "Filtered: {filterTitleStr}"
msgstr "" msgstr ""
#: src/components/media-post.jsx:133 #: src/components/media-post.jsx:133
#: src/components/status.jsx:3407 #: src/components/status.jsx:3413
#: src/components/status.jsx:3503 #: src/components/status.jsx:3509
#: src/components/status.jsx:3581 #: src/components/status.jsx:3587
#: src/components/timeline.jsx:971 #: src/components/timeline.jsx:971
#: src/pages/catchup.jsx:75 #: src/pages/catchup.jsx:75
#: src/pages/catchup.jsx:1859 #: src/pages/catchup.jsx:1859
@ -2094,7 +2094,7 @@ msgid "Edited: {editedDateText}"
msgstr "" msgstr ""
#: src/components/status.jsx:1123 #: src/components/status.jsx:1123
#: src/components/status.jsx:3084 #: src/components/status.jsx:3090
msgid "Embed post" msgid "Embed post"
msgstr "" msgstr ""
@ -2218,76 +2218,76 @@ msgstr ""
msgid "Comments" msgid "Comments"
msgstr "" msgstr ""
#: src/components/status.jsx:2845 #: src/components/status.jsx:2851
msgid "Edit History" msgid "Edit History"
msgstr "" msgstr ""
#: src/components/status.jsx:2849 #: src/components/status.jsx:2855
msgid "Failed to load history" msgid "Failed to load history"
msgstr "" msgstr ""
#: src/components/status.jsx:2854 #: src/components/status.jsx:2860
msgid "Loading…" msgid "Loading…"
msgstr "" msgstr ""
#: src/components/status.jsx:3089 #: src/components/status.jsx:3095
msgid "HTML Code" msgid "HTML Code"
msgstr "" msgstr ""
#: src/components/status.jsx:3106 #: src/components/status.jsx:3112
msgid "HTML code copied" msgid "HTML code copied"
msgstr "" msgstr ""
#: src/components/status.jsx:3109 #: src/components/status.jsx:3115
msgid "Unable to copy HTML code" msgid "Unable to copy HTML code"
msgstr "" msgstr ""
#: src/components/status.jsx:3121 #: src/components/status.jsx:3127
msgid "Media attachments:" msgid "Media attachments:"
msgstr "" msgstr ""
#: src/components/status.jsx:3143 #: src/components/status.jsx:3149
msgid "Account Emojis:" msgid "Account Emojis:"
msgstr "" msgstr ""
#: src/components/status.jsx:3174 #: src/components/status.jsx:3180
#: src/components/status.jsx:3219 #: src/components/status.jsx:3225
msgid "static URL" msgid "static URL"
msgstr "" msgstr ""
#: src/components/status.jsx:3188 #: src/components/status.jsx:3194
msgid "Emojis:" msgid "Emojis:"
msgstr "" msgstr ""
#: src/components/status.jsx:3233 #: src/components/status.jsx:3239
msgid "Notes:" msgid "Notes:"
msgstr "" 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." msgid "This is static, unstyled and scriptless. You may need to apply your own styles and edit as needed."
msgstr "" msgstr ""
#: src/components/status.jsx:3243 #: src/components/status.jsx:3249
msgid "Polls are not interactive, becomes a list with vote counts." msgid "Polls are not interactive, becomes a list with vote counts."
msgstr "" msgstr ""
#: src/components/status.jsx:3248 #: src/components/status.jsx:3254
msgid "Media attachments can be images, videos, audios or any file types." msgid "Media attachments can be images, videos, audios or any file types."
msgstr "" msgstr ""
#: src/components/status.jsx:3254 #: src/components/status.jsx:3260
msgid "Post could be edited or deleted later." msgid "Post could be edited or deleted later."
msgstr "" msgstr ""
#: src/components/status.jsx:3260 #: src/components/status.jsx:3266
msgid "Preview" msgid "Preview"
msgstr "" msgstr ""
#: src/components/status.jsx:3269 #: src/components/status.jsx:3275
msgid "Note: This preview is lightly styled." msgid "Note: This preview is lightly styled."
msgstr "" msgstr ""
#: src/components/status.jsx:3511 #: src/components/status.jsx:3517
msgid "<0/> <1/> boosted" msgid "<0/> <1/> boosted"
msgstr "" msgstr ""