canPreview -> canApplyWatermark

This commit is contained in:
kakkokari-gtyih 2024-12-19 23:37:20 +09:00
parent d1eadbd908
commit 7a9a71f2a4
5 changed files with 14 additions and 14 deletions

View file

@ -130,7 +130,7 @@ import { claimAchievement } from '@/scripts/achievements.js';
import { emojiPicker } from '@/scripts/emoji-picker.js';
import { mfmFunctionPicker } from '@/scripts/mfm-function-picker.js';
import type { PostFormProps } from '@/types/post-form.js';
import { canPreview } from '@/scripts/watermark';
import { canApplyWatermark } from '@/scripts/watermark';
const $i = signinRequired();
@ -602,7 +602,7 @@ async function onPaste(ev: ClipboardEvent) {
if (
shouldApplyWatermark == null &&
defaultStore.state.clipboardWatermarkBehavior === 'confirm' &&
canPreview(defaultStore.reactiveState.watermarkConfig.value)
canApplyWatermark(defaultStore.reactiveState.watermarkConfig.value)
) {
const { canceled } = await os.confirm({
type: 'info',

View file

@ -112,7 +112,7 @@ import * as os from '@/os.js';
import { defaultStore } from '@/store.js';
import { i18n } from '@/i18n.js';
import { selectFile } from '@/scripts/select-file.js';
import { applyWatermark, canPreview } from '@/scripts/watermark.js';
import { applyWatermark, canApplyWatermark } from '@/scripts/watermark.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import type { WatermarkUserConfig } from '@/scripts/watermark.js';
@ -201,7 +201,7 @@ const paddingBottom = computed({
});
function save() {
if (canPreview(watermarkConfig.value)) {
if (canApplyWatermark(watermarkConfig.value)) {
defaultStore.set('watermarkConfig', watermarkConfig.value);
} else {
os.alert({
@ -280,7 +280,7 @@ onMounted(() => {
canvasLoading.value = true;
if (canvasEl.value) {
// @/scripts/watermark.ts DEFAULT_ASPECT_RATIO 使
applyWatermark('/client-assets/hill.webp', canvasEl.value, canPreview(watermarkConfigTo) ? watermarkConfigTo : null).then(() => {
applyWatermark('/client-assets/hill.webp', canvasEl.value, canApplyWatermark(watermarkConfigTo) ? watermarkConfigTo : null).then(() => {
canvasLoading.value = false;
});
}

View file

@ -12,7 +12,7 @@ import { i18n } from '@/i18n.js';
import { defaultStore } from '@/store.js';
import { uploadFile } from '@/scripts/upload.js';
import type { MenuItem } from '@/types/menu.js';
import { canPreview } from './watermark.js';
import { canApplyWatermark } from './watermark.js';
export function chooseFileFromPc(opts?: {
multiple?: boolean;
@ -96,8 +96,8 @@ function select(src: HTMLElement | EventTarget | null, opts?: {
return new Promise((res, rej) => {
const keepOriginal = ref(defaultStore.state.keepOriginalUploading);
const watermarkCanPreview = canPreview(defaultStore.reactiveState.watermarkConfig.value);
const useWatermark = ref(opts?.dontUseWatermark || !watermarkCanPreview ? false : defaultStore.state.useWatermark);
const watermarkcanApplyWatermark = canApplyWatermark(defaultStore.reactiveState.watermarkConfig.value);
const useWatermark = ref(opts?.dontUseWatermark || !watermarkcanApplyWatermark ? false : defaultStore.state.useWatermark);
const menu: MenuItem[] = [];
@ -118,7 +118,7 @@ function select(src: HTMLElement | EventTarget | null, opts?: {
menu.push({
type: 'switch',
text: i18n.ts.useWatermark,
disabled: !watermarkCanPreview,
disabled: !watermarkcanApplyWatermark,
ref: useWatermark,
});
}

View file

@ -14,7 +14,7 @@ import { $i } from '@/account.js';
import { alert } from '@/os.js';
import { i18n } from '@/i18n.js';
import { instance } from '@/instance.js';
import { canPreview, getWatermarkAppliedImage } from './watermark.js';
import { canApplyWatermark, getWatermarkAppliedImage } from './watermark.js';
type Uploading = {
id: string;
@ -71,7 +71,7 @@ export function uploadFile(
let _file: Blob = file;
if (_file.type.startsWith('image/') && watermark && canPreview(defaultStore.state.watermarkConfig)) {
if (_file.type.startsWith('image/') && watermark && canApplyWatermark(defaultStore.state.watermarkConfig)) {
_file = await getWatermarkAppliedImage(_file, defaultStore.state.watermarkConfig);
}

View file

@ -22,7 +22,7 @@ export type WatermarkAnchor = typeof watermarkAnchor[number];
/**
* Storeへの保存やエディタで使用するための
* `canPreview``WatermarkConfig`
* `canApplyWatermark``WatermarkConfig`
*
*
*/
@ -58,7 +58,7 @@ export type WatermarkUserConfig = {
/**
* Canvasへの描画などで使用できる
* `WatermarkUserConfig``canPreview`
* `WatermarkUserConfig``canApplyWatermark`
*
*
*/
@ -101,7 +101,7 @@ const DEFAULT_ASPECT_RATIO = 4 / 3;
/**
*
*/
export function canPreview(config: Partial<WatermarkConfig | WatermarkUserConfig> | null): config is WatermarkConfig {
export function canApplyWatermark(config: Partial<WatermarkConfig | WatermarkUserConfig> | null): config is WatermarkConfig {
return (
config != null &&
(config.fileUrl != null || config.fileId != null) &&