From 1dce84dfe31325be8687ad6738445b050df7ff9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=BE=E3=81=A3=E3=81=A1=E3=82=83=E3=81=A8=E3=83=BC?= =?UTF-8?q?=E3=81=AB=E3=82=85?= <17376330+u1-liquid@users.noreply.github.com> Date: Thu, 22 Feb 2024 08:06:07 +0900 Subject: [PATCH] fix code quality issues --- packages/backend/src/core/FileInfoService.ts | 28 ++++++------------- .../components/MkSourceCodeAvailablePopup.vue | 4 +-- packages/frontend/src/pages/reversi/game.vue | 2 +- 3 files changed, 10 insertions(+), 24 deletions(-) diff --git a/packages/backend/src/core/FileInfoService.ts b/packages/backend/src/core/FileInfoService.ts index b8babcb3a..f3e93b9db 100644 --- a/packages/backend/src/core/FileInfoService.ts +++ b/packages/backend/src/core/FileInfoService.ts @@ -14,7 +14,6 @@ import FFmpeg from 'fluent-ffmpeg'; import isSvg from 'is-svg'; import probeImageSize from 'probe-image-size'; import { type predictionType } from 'nsfwjs'; -import sharp from 'sharp'; import { sharpBmp } from '@misskey-dev/sharp-read-bmp'; import { encode } from 'blurhash'; import { createTempDir } from '@/misc/create-temp.js'; @@ -408,25 +407,14 @@ export class FileInfoService { * Calculate average color of image */ @bindThis - private getBlurhash(path: string, type: string): Promise { - return new Promise(async (resolve, reject) => { - (await sharpBmp(path, type)) - .raw() - .ensureAlpha() - .resize(64, 64, { fit: 'inside' }) - .toBuffer((err, buffer, info) => { - if (err) return reject(err); + private async getBlurhash(path: string, type: string): Promise { + const sharp = await sharpBmp(path, type); + const { data, info } = await sharp + .raw() + .ensureAlpha() + .resize(64, 64, { fit: 'inside' }) + .toBuffer({ resolveWithObject: true }); - let hash; - - try { - hash = encode(new Uint8ClampedArray(buffer), info.width, info.height, 5, 5); - } catch (e) { - return reject(e); - } - - resolve(hash); - }); - }); + return encode(new Uint8ClampedArray(data), info.width, info.height, 5, 5); } } diff --git a/packages/frontend/src/components/MkSourceCodeAvailablePopup.vue b/packages/frontend/src/components/MkSourceCodeAvailablePopup.vue index 80f3a6709..f6cdc4bf3 100644 --- a/packages/frontend/src/components/MkSourceCodeAvailablePopup.vue +++ b/packages/frontend/src/components/MkSourceCodeAvailablePopup.vue @@ -47,9 +47,7 @@ import { instance } from '@/instance.js'; import { miLocalStorage } from '@/local-storage.js'; import * as os from '@/os.js'; -const emit = defineEmits<{ - (ev: 'closed'): void; -}>(); +const emit = defineEmits<(ev: 'closed') => void>(); const zIndex = os.claimZIndex('low'); diff --git a/packages/frontend/src/pages/reversi/game.vue b/packages/frontend/src/pages/reversi/game.vue index dc37a3bf1..d95dce18a 100644 --- a/packages/frontend/src/pages/reversi/game.vue +++ b/packages/frontend/src/pages/reversi/game.vue @@ -10,7 +10,7 @@ SPDX-License-Identifier: AGPL-3.0-only