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 @@ -45,6 +45,7 @@
- Fix: Twitchの埋め込みが開けない問題を修正
- Fix: 子メニューの高さがウィンドウからはみ出ることがある問題を修正
- Fix: 個人宛てのダイアログ形式のお知らせが即時表示されない問題を修正
- Fix: 一部の画像がセンシティブ指定されているときに画面に何も表示されないことがあるのを修正

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

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

const color = (props.hash != null && extractAvgColorFromBlurhash(props.hash)) || '#888';

const ctx = canvas.value.getContext('2d');
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;
if (import.meta.env.MODE === 'test' && props.hash == null) return;

drawAvg();

if (props.hash == null) return;

if (props.onlyAvgColor) return;

const work = await canvasPromise;
Expand Down
Loading