Skip to content

Commit

Permalink
fix(frontend): blurhashが無い場合に何も出力されないのを修正 (misskey-dev#14250)
Browse files Browse the repository at this point in the history
* fix(frontend): blurhashが無い場合に何も出力されないのを修正

* Update Changelog

* Update packages/frontend/src/components/MkImgWithBlurhash.vue

Co-authored-by: tamaina <[email protected]>

* attempt to fix test

* Update packages/frontend/src/components/MkImgWithBlurhash.vue

Co-authored-by: tamaina <[email protected]>

* attempt to ignore test

---------

Co-authored-by: tamaina <[email protected]>
  • Loading branch information
kakkokari-gtyih and tamaina authored Jul 19, 2024
1 parent 6920f0f commit 56a43dc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
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

0 comments on commit 56a43dc

Please sign in to comment.