From 9c225384541192bbd83da94ac2f6c09ade3a25e8 Mon Sep 17 00:00:00 2001 From: かっこかり <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Fri, 2 Jan 2026 21:41:32 +0900 Subject: fix(frontend): ファイルタブのセンシティブメディアを開く際に確認ダイアログを出す設定が適用されない問題を修正 (#17019) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(frontend): ファイルタブのセンシティブメディアを開く際に確認ダイアログを出す設定が適用されない問題を修正 * Update Changelog * refactor * Update Changelog --- packages/frontend/src/utility/sensitive-file.ts | 33 +++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 packages/frontend/src/utility/sensitive-file.ts (limited to 'packages/frontend/src/utility/sensitive-file.ts') diff --git a/packages/frontend/src/utility/sensitive-file.ts b/packages/frontend/src/utility/sensitive-file.ts new file mode 100644 index 0000000000..f1fc909e4a --- /dev/null +++ b/packages/frontend/src/utility/sensitive-file.ts @@ -0,0 +1,33 @@ +/* + * SPDX-FileCopyrightText: syuilo and misskey-project + * SPDX-License-Identifier: AGPL-3.0-only + */ + +import * as Misskey from 'misskey-js'; +import * as os from '@/os.js'; +import { prefer } from '@/preferences.js'; +import { i18n } from '@/i18n.js'; + +export function shouldHideFileByDefault(file: Misskey.entities.DriveFile): boolean { + if (prefer.s.nsfw === 'force' || prefer.s.dataSaver.media) { + return true; + } + + if (file.isSensitive && prefer.s.nsfw !== 'ignore') { + return true; + } + + return false; +} + +export async function canRevealFile(file: Misskey.entities.DriveFile): Promise { + if (file.isSensitive && prefer.s.confirmWhenRevealingSensitiveMedia) { + const { canceled } = await os.confirm({ + type: 'question', + text: i18n.ts.sensitiveMediaRevealConfirm, + }); + if (canceled) return false; + } + + return true; +} -- cgit v1.2.3-freya