Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(frontend): blurhashが無い場合に何も出力されないのを修正 #14250

Merged
merged 9 commits into from
Jul 19, 2024
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
(Cherry-picked from https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/574)
- Fix: Twitchの埋め込みが開けない問題を修正
- Fix: 子メニューの高さがウィンドウからはみ出ることがある問題を修正
- Fix: 一部の画像がセンシティブ指定されているときに画面に何も表示されないことがあるのを修正

### Server
- Feat: レートリミット制限に引っかかったときに`Retry-After`ヘッダーを返すように (#13949)
Expand Down
14 changes: 10 additions & 4 deletions packages/frontend/src/components/MkImgWithBlurhash.vue
Original file line number Diff line number Diff line change
Expand Up @@ -151,22 +151,28 @@
}

function drawAvg() {
if (!canvas.value || !props.hash) return;
if (!canvas.value) return;

let color = '#888'; // blurhashが無い場合のフォールバック

if (props.hash != null) {
color = extractAvgColorFromBlurhash(props.hash) ?? '#888';
}
kakkokari-gtyih marked this conversation as resolved.
Show resolved Hide resolved

const ctx = canvas.value.getContext('2d');

Check failure on line 162 in packages/frontend/src/components/MkImgWithBlurhash.vue

View workflow job for this annotation

GitHub Actions / vitest (20.12.2)

Unhandled error

TypeError: canvas.value.getContext is not a function ❯ drawAvg src/components/MkImgWithBlurhash.vue:162:27 ❯ draw src/components/MkImgWithBlurhash.vue:172:2 ❯ src/components/MkImgWithBlurhash.vue:207:2 This error originated in "test/note.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running.

Check failure on line 162 in packages/frontend/src/components/MkImgWithBlurhash.vue

View workflow job for this annotation

GitHub Actions / vitest (20.12.2)

Unhandled error

TypeError: canvas.value.getContext is not a function ❯ drawAvg src/components/MkImgWithBlurhash.vue:162:27 ❯ draw src/components/MkImgWithBlurhash.vue:172:2 ❯ src/components/MkImgWithBlurhash.vue:207:2 This error originated in "test/note.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running.

Check failure on line 162 in packages/frontend/src/components/MkImgWithBlurhash.vue

View workflow job for this annotation

GitHub Actions / vitest (20.12.2)

Unhandled error

TypeError: canvas.value.getContext is not a function ❯ drawAvg src/components/MkImgWithBlurhash.vue:162:27 ❯ draw src/components/MkImgWithBlurhash.vue:172:2 ❯ src/components/MkImgWithBlurhash.vue:207:2 This error originated in "test/note.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running.

Check failure on line 162 in packages/frontend/src/components/MkImgWithBlurhash.vue

View workflow job for this annotation

GitHub Actions / vitest (20.12.2)

Unhandled error

TypeError: canvas.value.getContext is not a function ❯ drawAvg src/components/MkImgWithBlurhash.vue:162:27 ❯ draw src/components/MkImgWithBlurhash.vue:172:2 ❯ src/components/MkImgWithBlurhash.vue:207:2 This error originated in "test/note.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running.

Check failure on line 162 in packages/frontend/src/components/MkImgWithBlurhash.vue

View workflow job for this annotation

GitHub Actions / vitest (20.12.2)

Unhandled error

TypeError: canvas.value.getContext is not a function ❯ drawAvg src/components/MkImgWithBlurhash.vue:162:27 ❯ draw src/components/MkImgWithBlurhash.vue:172:2 ❯ src/components/MkImgWithBlurhash.vue:207:2 This error originated in "test/note.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running.

Check failure on line 162 in packages/frontend/src/components/MkImgWithBlurhash.vue

View workflow job for this annotation

GitHub Actions / vitest (20.12.2)

Unhandled error

TypeError: canvas.value.getContext is not a function ❯ drawAvg src/components/MkImgWithBlurhash.vue:162:27 ❯ draw src/components/MkImgWithBlurhash.vue:172:2 ❯ src/components/MkImgWithBlurhash.vue:207:2 This error originated in "test/home.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running.

Check failure on line 162 in packages/frontend/src/components/MkImgWithBlurhash.vue

View workflow job for this annotation

GitHub Actions / vitest (20.12.2)

Unhandled error

TypeError: canvas.value.getContext is not a function ❯ drawAvg src/components/MkImgWithBlurhash.vue:162:27 ❯ draw src/components/MkImgWithBlurhash.vue:172:2 ❯ src/components/MkImgWithBlurhash.vue:207:2 This error originated in "test/home.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running.
if (!ctx) return;

// avgColorでお茶をにごす
ctx.beginPath();
ctx.fillStyle = extractAvgColorFromBlurhash(props.hash) ?? '#888';
ctx.fillStyle = color;
ctx.fillRect(0, 0, canvasWidth.value, canvasHeight.value);
}

async function draw() {
if (props.hash == null) return;

drawAvg();

if (props.hash == null) return;

if (props.onlyAvgColor) return;

const work = await canvasPromise;
Expand Down
Loading