mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-27 10:20:27 +01:00
canPreview -> canApplyWatermark
This commit is contained in:
parent
d1eadbd908
commit
7a9a71f2a4
5 changed files with 14 additions and 14 deletions
|
@ -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',
|
||||
|
|
|
@ -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;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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) &&
|
||||
|
|
Loading…
Reference in a new issue