refactor(frontend): asとanyをすぐなおせる範囲で除去 (#14848)
* refactor(frontend): できるだけanyを除去 * refactor * lint * fix * remove unused * Update packages/frontend/src/components/MkReactionsViewer.details.vue * Update packages/frontend/src/components/MkUsersTooltip.vue --------- Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
This commit is contained in:
		| @@ -99,19 +99,19 @@ async function addUser() { | ||||
| 	const { canceled: canceled1, result: username } = await os.inputText({ | ||||
| 		title: i18n.ts.username, | ||||
| 	}); | ||||
| 	if (canceled1) return; | ||||
| 	if (canceled1 || username == null) return; | ||||
|  | ||||
| 	const { canceled: canceled2, result: password } = await os.inputText({ | ||||
| 		title: i18n.ts.password, | ||||
| 		type: 'password', | ||||
| 	}); | ||||
| 	if (canceled2) return; | ||||
| 	if (canceled2 || password == null) return; | ||||
|  | ||||
| 	os.apiWithDialog('admin/accounts/create', { | ||||
| 		username: username, | ||||
| 		password: password, | ||||
| 	}).then(res => { | ||||
| 		paginationComponent.value.reload(); | ||||
| 		paginationComponent.value?.reload(); | ||||
| 	}); | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -116,7 +116,7 @@ const selectAll = () => { | ||||
| 	if (selectedEmojis.value.length > 0) { | ||||
| 		selectedEmojis.value = []; | ||||
| 	} else { | ||||
| 		selectedEmojis.value = Array.from(emojisPaginationComponent.value.items.values(), item => item.id); | ||||
| 		selectedEmojis.value = Array.from(emojisPaginationComponent.value?.items.values(), item => item.id); | ||||
| 	} | ||||
| }; | ||||
|  | ||||
| @@ -133,7 +133,7 @@ const add = async (ev: MouseEvent) => { | ||||
| 	}, { | ||||
| 		done: result => { | ||||
| 			if (result.created) { | ||||
| 				emojisPaginationComponent.value.prepend(result.created); | ||||
| 				emojisPaginationComponent.value?.prepend(result.created); | ||||
| 			} | ||||
| 		}, | ||||
| 		closed: () => dispose(), | ||||
| @@ -146,12 +146,12 @@ const edit = (emoji) => { | ||||
| 	}, { | ||||
| 		done: result => { | ||||
| 			if (result.updated) { | ||||
| 				emojisPaginationComponent.value.updateItem(result.updated.id, (oldEmoji: any) => ({ | ||||
| 				emojisPaginationComponent.value?.updateItem(result.updated.id, (oldEmoji) => ({ | ||||
| 					...oldEmoji, | ||||
| 					...result.updated, | ||||
| 				})); | ||||
| 			} else if (result.deleted) { | ||||
| 				emojisPaginationComponent.value.removeItem(emoji.id); | ||||
| 				emojisPaginationComponent.value?.removeItem(emoji.id); | ||||
| 			} | ||||
| 		}, | ||||
| 		closed: () => dispose(), | ||||
| @@ -226,7 +226,7 @@ const setCategoryBulk = async () => { | ||||
| 		ids: selectedEmojis.value, | ||||
| 		category: result, | ||||
| 	}); | ||||
| 	emojisPaginationComponent.value.reload(); | ||||
| 	emojisPaginationComponent.value?.reload(); | ||||
| }; | ||||
|  | ||||
| const setLicenseBulk = async () => { | ||||
| @@ -238,43 +238,43 @@ const setLicenseBulk = async () => { | ||||
| 		ids: selectedEmojis.value, | ||||
| 		license: result, | ||||
| 	}); | ||||
| 	emojisPaginationComponent.value.reload(); | ||||
| 	emojisPaginationComponent.value?.reload(); | ||||
| }; | ||||
|  | ||||
| const addTagBulk = async () => { | ||||
| 	const { canceled, result } = await os.inputText({ | ||||
| 		title: 'Tag', | ||||
| 	}); | ||||
| 	if (canceled) return; | ||||
| 	if (canceled || result == null) return; | ||||
| 	await os.apiWithDialog('admin/emoji/add-aliases-bulk', { | ||||
| 		ids: selectedEmojis.value, | ||||
| 		aliases: result.split(' '), | ||||
| 	}); | ||||
| 	emojisPaginationComponent.value.reload(); | ||||
| 	emojisPaginationComponent.value?.reload(); | ||||
| }; | ||||
|  | ||||
| const removeTagBulk = async () => { | ||||
| 	const { canceled, result } = await os.inputText({ | ||||
| 		title: 'Tag', | ||||
| 	}); | ||||
| 	if (canceled) return; | ||||
| 	if (canceled || result == null) return; | ||||
| 	await os.apiWithDialog('admin/emoji/remove-aliases-bulk', { | ||||
| 		ids: selectedEmojis.value, | ||||
| 		aliases: result.split(' '), | ||||
| 	}); | ||||
| 	emojisPaginationComponent.value.reload(); | ||||
| 	emojisPaginationComponent.value?.reload(); | ||||
| }; | ||||
|  | ||||
| const setTagBulk = async () => { | ||||
| 	const { canceled, result } = await os.inputText({ | ||||
| 		title: 'Tag', | ||||
| 	}); | ||||
| 	if (canceled) return; | ||||
| 	if (canceled || result == null) return; | ||||
| 	await os.apiWithDialog('admin/emoji/set-aliases-bulk', { | ||||
| 		ids: selectedEmojis.value, | ||||
| 		aliases: result.split(' '), | ||||
| 	}); | ||||
| 	emojisPaginationComponent.value.reload(); | ||||
| 	emojisPaginationComponent.value?.reload(); | ||||
| }; | ||||
|  | ||||
| const delBulk = async () => { | ||||
| @@ -286,7 +286,7 @@ const delBulk = async () => { | ||||
| 	await os.apiWithDialog('admin/emoji/delete-bulk', { | ||||
| 		ids: selectedEmojis.value, | ||||
| 	}); | ||||
| 	emojisPaginationComponent.value.reload(); | ||||
| 	emojisPaginationComponent.value?.reload(); | ||||
| }; | ||||
|  | ||||
| const headerActions = computed(() => [{ | ||||
|   | ||||
| @@ -95,14 +95,14 @@ import { selectFile } from '@/scripts/select-file.js'; | ||||
| import MkRolePreview from '@/components/MkRolePreview.vue'; | ||||
|  | ||||
| const props = defineProps<{ | ||||
| 	emoji?: any, | ||||
| 	emoji?: Misskey.entities.EmojiDetailed, | ||||
| }>(); | ||||
|  | ||||
| const windowEl = ref<InstanceType<typeof MkWindow> | null>(null); | ||||
| const name = ref<string>(props.emoji ? props.emoji.name : ''); | ||||
| const category = ref<string>(props.emoji ? props.emoji.category : ''); | ||||
| const category = ref<string>(props.emoji?.category ? props.emoji.category : ''); | ||||
| const aliases = ref<string>(props.emoji ? props.emoji.aliases.join(' ') : ''); | ||||
| const license = ref<string>(props.emoji ? (props.emoji.license ?? '') : ''); | ||||
| const license = ref<string>(props.emoji?.license ? props.emoji.license : ''); | ||||
| const isSensitive = ref(props.emoji ? props.emoji.isSensitive : false); | ||||
| const localOnly = ref(props.emoji ? props.emoji.localOnly : false); | ||||
| const roleIdsThatCanBeUsedThisEmojiAsReaction = ref(props.emoji ? props.emoji.roleIdsThatCanBeUsedThisEmojiAsReaction : []); | ||||
| @@ -116,11 +116,11 @@ watch(roleIdsThatCanBeUsedThisEmojiAsReaction, async () => { | ||||
| const imgUrl = computed(() => file.value ? file.value.url : props.emoji ? `/emoji/${props.emoji.name}.webp` : null); | ||||
|  | ||||
| const emit = defineEmits<{ | ||||
| 	(ev: 'done', v: { deleted?: boolean; updated?: any; created?: any }): void, | ||||
| 	(ev: 'done', v: { deleted?: boolean; updated?: Misskey.entities.AdminEmojiUpdateRequest; created?: Misskey.entities.AdminEmojiUpdateRequest }): void, | ||||
| 	(ev: 'closed'): void | ||||
| }>(); | ||||
|  | ||||
| async function changeImage(ev) { | ||||
| async function changeImage(ev: Event) { | ||||
| 	file.value = await selectFile(ev.currentTarget ?? ev.target, null); | ||||
| 	const candidate = file.value.name.replace(/\.(.+)$/, ''); | ||||
| 	if (candidate.match(/^[a-z0-9_]+$/)) { | ||||
| @@ -140,7 +140,7 @@ async function addRole() { | ||||
| 	rolesThatCanBeUsedThisEmojiAsReaction.value.push(role); | ||||
| } | ||||
|  | ||||
| async function removeRole(role, ev) { | ||||
| async function removeRole(role: Misskey.entities.RoleLite, ev: Event) { | ||||
| 	rolesThatCanBeUsedThisEmojiAsReaction.value = rolesThatCanBeUsedThisEmojiAsReaction.value.filter(x => x.id !== role.id); | ||||
| } | ||||
|  | ||||
| @@ -172,7 +172,7 @@ async function done() { | ||||
| 			}, | ||||
| 		}); | ||||
|  | ||||
| 		windowEl.value.close(); | ||||
| 		windowEl.value?.close(); | ||||
| 	} else { | ||||
| 		const created = await os.apiWithDialog('admin/emoji/add', params); | ||||
|  | ||||
| @@ -180,11 +180,12 @@ async function done() { | ||||
| 			created: created, | ||||
| 		}); | ||||
|  | ||||
| 		windowEl.value.close(); | ||||
| 		windowEl.value?.close(); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| async function del() { | ||||
| 	if (!props.emoji) return; | ||||
| 	const { canceled } = await os.confirm({ | ||||
| 		type: 'warning', | ||||
| 		text: i18n.tsx.removeAreYouSure({ x: name.value }), | ||||
| @@ -197,7 +198,7 @@ async function del() { | ||||
| 		emit('done', { | ||||
| 			deleted: true, | ||||
| 		}); | ||||
| 		windowEl.value.close(); | ||||
| 		windowEl.value?.close(); | ||||
| 	}); | ||||
| } | ||||
| </script> | ||||
|   | ||||
| @@ -55,13 +55,13 @@ const pagination = { | ||||
|  | ||||
| function accept(user) { | ||||
| 	misskeyApi('following/requests/accept', { userId: user.id }).then(() => { | ||||
| 		paginationComponent.value.reload(); | ||||
| 		paginationComponent.value?.reload(); | ||||
| 	}); | ||||
| } | ||||
|  | ||||
| function reject(user) { | ||||
| 	misskeyApi('following/requests/reject', { userId: user.id }).then(() => { | ||||
| 		paginationComponent.value.reload(); | ||||
| 		paginationComponent.value?.reload(); | ||||
| 	}); | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -40,7 +40,7 @@ function fetch() { | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	let promise: Promise<any>; | ||||
| 	let promise: Promise<unknown>; | ||||
|  | ||||
| 	if (uri.startsWith('https://')) { | ||||
| 		promise = misskeyApi('ap/show', { | ||||
|   | ||||
| @@ -77,15 +77,15 @@ async function create() { | ||||
|  | ||||
| 	clipsCache.delete(); | ||||
|  | ||||
| 	pagingComponent.value.reload(); | ||||
| 	pagingComponent.value?.reload(); | ||||
| } | ||||
|  | ||||
| function onClipCreated() { | ||||
| 	pagingComponent.value.reload(); | ||||
| 	pagingComponent.value?.reload(); | ||||
| } | ||||
|  | ||||
| function onClipDeleted() { | ||||
| 	pagingComponent.value.reload(); | ||||
| 	pagingComponent.value?.reload(); | ||||
| } | ||||
|  | ||||
| const headerActions = computed(() => []); | ||||
|   | ||||
| @@ -110,7 +110,7 @@ function addUser() { | ||||
| 			listId: list.value.id, | ||||
| 			userId: user.id, | ||||
| 		}).then(() => { | ||||
| 			paginationEl.value.reload(); | ||||
| 			paginationEl.value?.reload(); | ||||
| 		}); | ||||
| 	}); | ||||
| } | ||||
| @@ -126,7 +126,7 @@ async function removeUser(item, ev) { | ||||
| 				listId: list.value.id, | ||||
| 				userId: item.userId, | ||||
| 			}).then(() => { | ||||
| 				paginationEl.value.removeItem(item.id); | ||||
| 				paginationEl.value?.removeItem(item.id); | ||||
| 			}); | ||||
| 		}, | ||||
| 	}], ev.currentTarget ?? ev.target); | ||||
|   | ||||
| @@ -30,11 +30,12 @@ import { misskeyApi } from '@/scripts/misskey-api.js'; | ||||
| import { i18n } from '@/i18n.js'; | ||||
|  | ||||
| const props = defineProps<{ | ||||
| 	modelValue: any | ||||
| 	modelValue: Misskey.entities.PageBlock & { type: 'image' }; | ||||
| }>(); | ||||
|  | ||||
| const emit = defineEmits<{ | ||||
| 	(ev: 'update:modelValue', value: any): void; | ||||
| 	(ev: 'update:modelValue', value: Misskey.entities.PageBlock & { type: 'image' }): void; | ||||
| 	(ev: 'remove'): void; | ||||
| }>(); | ||||
|  | ||||
| const file = ref<Misskey.entities.DriveFile | null>(null); | ||||
|   | ||||
| @@ -34,19 +34,24 @@ import { misskeyApi } from '@/scripts/misskey-api.js'; | ||||
| import { i18n } from '@/i18n.js'; | ||||
|  | ||||
| const props = defineProps<{ | ||||
| 	modelValue: any | ||||
| 	modelValue: Misskey.entities.PageBlock & { type: 'note' }; | ||||
| }>(); | ||||
|  | ||||
| const emit = defineEmits<{ | ||||
| 	(ev: 'update:modelValue', value: any): void; | ||||
| 	(ev: 'update:modelValue', value: Misskey.entities.PageBlock & { type: 'note' }): void; | ||||
| }>(); | ||||
|  | ||||
| const id = ref<any>(props.modelValue.note); | ||||
| const id = ref(props.modelValue.note); | ||||
| const note = ref<Misskey.entities.Note | null>(null); | ||||
|  | ||||
| watch(id, async () => { | ||||
| 	if (id.value && (id.value.startsWith('http://') || id.value.startsWith('https://'))) { | ||||
| 		id.value = (id.value.endsWith('/') ? id.value.slice(0, -1) : id.value).split('/').pop(); | ||||
| 		id.value = (id.value.endsWith('/') ? id.value.slice(0, -1) : id.value).split('/').pop() ?? null; | ||||
| 	} | ||||
|  | ||||
| 	if (!id.value) { | ||||
| 		note.value = null; | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	emit('update:modelValue', { | ||||
|   | ||||
| @@ -23,6 +23,7 @@ SPDX-License-Identifier: AGPL-3.0-only | ||||
| <script lang="ts" setup> | ||||
| /* eslint-disable vue/no-mutating-props */ | ||||
| import { defineAsyncComponent, inject, onMounted, watch, ref } from 'vue'; | ||||
| import * as Misskey from 'misskey-js'; | ||||
| import { v4 as uuid } from 'uuid'; | ||||
| import XContainer from '../page-editor.container.vue'; | ||||
| import * as os from '@/os.js'; | ||||
| @@ -33,14 +34,13 @@ import { getPageBlockList } from '@/pages/page-editor/common.js'; | ||||
|  | ||||
| const XBlocks = defineAsyncComponent(() => import('../page-editor.blocks.vue')); | ||||
|  | ||||
| const props = withDefaults(defineProps<{ | ||||
| 	modelValue: any, | ||||
| }>(), { | ||||
| 	modelValue: {}, | ||||
| }); | ||||
| const props = defineProps<{ | ||||
| 	modelValue: Misskey.entities.PageBlock & { type: 'section'; }, | ||||
| }>(); | ||||
|  | ||||
| const emit = defineEmits<{ | ||||
| 	(ev: 'update:modelValue', value: any): void; | ||||
| 	(ev: 'update:modelValue', value: Misskey.entities.PageBlock & { type: 'section' }): void; | ||||
| 	(ev: 'remove'): void; | ||||
| }>(); | ||||
|  | ||||
| const children = ref(deepClone(props.modelValue.children ?? [])); | ||||
|   | ||||
| @@ -17,16 +17,17 @@ SPDX-License-Identifier: AGPL-3.0-only | ||||
| <script lang="ts" setup> | ||||
| /* eslint-disable vue/no-mutating-props */ | ||||
| import { watch, ref, shallowRef, onMounted, onUnmounted } from 'vue'; | ||||
| import * as Misskey from 'misskey-js'; | ||||
| import XContainer from '../page-editor.container.vue'; | ||||
| import { i18n } from '@/i18n.js'; | ||||
| import { Autocomplete } from '@/scripts/autocomplete.js'; | ||||
|  | ||||
| const props = defineProps<{ | ||||
| 	modelValue: any | ||||
| 	modelValue: Misskey.entities.PageBlock & { type: 'text' } | ||||
| }>(); | ||||
|  | ||||
| const emit = defineEmits<{ | ||||
| 	(ev: 'update:modelValue', value: any): void; | ||||
| 	(ev: 'update:modelValue', value: Misskey.entities.PageBlock & { type: 'text' }): void; | ||||
| }>(); | ||||
|  | ||||
| let autocomplete: Autocomplete; | ||||
|   | ||||
| @@ -52,7 +52,7 @@ const props = defineProps<{ | ||||
|  | ||||
| const scope = computed(() => props.path ? props.path.split('/') : []); | ||||
|  | ||||
| const keys = ref<any>(null); | ||||
| const keys = ref<[string, string][]>([]); | ||||
|  | ||||
| function fetchKeys() { | ||||
| 	misskeyApi('i/registry/keys-with-type', { | ||||
|   | ||||
| @@ -132,7 +132,7 @@ const mapCategories = Array.from(new Set(Object.values(Reversi.maps).map(x => x. | ||||
|  | ||||
| const props = defineProps<{ | ||||
| 	game: Misskey.entities.ReversiGameDetailed; | ||||
| 	connection: Misskey.ChannelConnection; | ||||
| 	connection: Misskey.ChannelConnection<Misskey.Channels['reversiGame']>; | ||||
| }>(); | ||||
|  | ||||
| const shareWhenStart = defineModel<boolean>('shareWhenStart', { default: false }); | ||||
| @@ -217,14 +217,14 @@ function onChangeReadyStates(states) { | ||||
| 	game.value.user2Ready = states.user2; | ||||
| } | ||||
|  | ||||
| function updateSettings(key: keyof Misskey.entities.ReversiGameDetailed) { | ||||
| function updateSettings(key: typeof Misskey.reversiUpdateKeys[number]) { | ||||
| 	props.connection.send('updateSettings', { | ||||
| 		key: key, | ||||
| 		value: game.value[key], | ||||
| 	}); | ||||
| } | ||||
|  | ||||
| function onUpdateSettings({ userId, key, value }: { userId: string; key: keyof Misskey.entities.ReversiGameDetailed; value: any; }) { | ||||
| function onUpdateSettings<K extends typeof Misskey.reversiUpdateKeys[number]>({ userId, key, value }: { userId: string; key: K; value: Misskey.entities.ReversiGameDetailed[K]; }) { | ||||
| 	if (userId === $i.id) return; | ||||
| 	if (game.value[key] === value) return; | ||||
| 	game.value[key] = value; | ||||
|   | ||||
| @@ -76,7 +76,11 @@ import { claimAchievement } from '@/scripts/achievements.js'; | ||||
| const parser = new Parser(); | ||||
| let aiscript: Interpreter; | ||||
| const code = ref(''); | ||||
| const logs = ref<any[]>([]); | ||||
| const logs = ref<{ | ||||
| 	id: number; | ||||
| 	text: string; | ||||
| 	print: boolean; | ||||
| }[]>([]); | ||||
| const root = ref<AsUiRoot>(); | ||||
| const components = ref<Ref<AsUiComponent>[]>([]); | ||||
| const uiKey = ref(0); | ||||
|   | ||||
| @@ -138,12 +138,13 @@ const token = ref<string | number | null>(null); | ||||
| const backupCodes = ref<string[]>(); | ||||
|  | ||||
| function cancel() { | ||||
| 	dialog.value.close(); | ||||
| 	dialog.value?.close(); | ||||
| } | ||||
|  | ||||
| async function tokenDone() { | ||||
| 	if (token.value == null) return; | ||||
| 	const res = await os.apiWithDialog('i/2fa/done', { | ||||
| 		token: token.value.toString(), | ||||
| 		token: typeof token.value === 'string' ? token.value : token.value.toString(), | ||||
| 	}); | ||||
|  | ||||
| 	backupCodes.value = res.backupCodes; | ||||
| @@ -166,7 +167,7 @@ function downloadBackupCodes() { | ||||
| } | ||||
|  | ||||
| function allDone() { | ||||
| 	dialog.value.close(); | ||||
| 	dialog.value?.close(); | ||||
| } | ||||
| </script> | ||||
|  | ||||
|   | ||||
| @@ -90,7 +90,7 @@ function createAccount() { | ||||
| 	}); | ||||
| } | ||||
|  | ||||
| async function switchAccount(account: any) { | ||||
| async function switchAccount(account: Misskey.entities.UserDetailed) { | ||||
| 	const fetchedAccounts = await getAccounts(); | ||||
| 	const token = fetchedAccounts.find(x => x.id === account.id)!.token; | ||||
| 	switchAccountWithToken(token); | ||||
|   | ||||
| @@ -55,6 +55,7 @@ SPDX-License-Identifier: AGPL-3.0-only | ||||
|  | ||||
| <script lang="ts" setup> | ||||
| import { ref, computed } from 'vue'; | ||||
| import * as Misskey from 'misskey-js'; | ||||
| import FormPagination from '@/components/MkPagination.vue'; | ||||
| import { misskeyApi } from '@/scripts/misskey-api.js'; | ||||
| import { i18n } from '@/i18n.js'; | ||||
| @@ -77,7 +78,7 @@ const pagination = { | ||||
|  | ||||
| function revoke(token) { | ||||
| 	misskeyApi('i/revoke-token', { tokenId: token.id }).then(() => { | ||||
| 		list.value.reload(); | ||||
| 		list.value?.reload(); | ||||
| 	}); | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -110,7 +110,7 @@ const decorationsForPreview = computed(() => { | ||||
| }); | ||||
|  | ||||
| function cancel() { | ||||
| 	dialog.value.close(); | ||||
| 	dialog.value?.close(); | ||||
| } | ||||
|  | ||||
| async function update() { | ||||
| @@ -120,7 +120,7 @@ async function update() { | ||||
| 		offsetX: offsetX.value, | ||||
| 		offsetY: offsetY.value, | ||||
| 	}); | ||||
| 	dialog.value.close(); | ||||
| 	dialog.value?.close(); | ||||
| } | ||||
|  | ||||
| async function attach() { | ||||
| @@ -130,12 +130,12 @@ async function attach() { | ||||
| 		offsetX: offsetX.value, | ||||
| 		offsetY: offsetY.value, | ||||
| 	}); | ||||
| 	dialog.value.close(); | ||||
| 	dialog.value?.close(); | ||||
| } | ||||
|  | ||||
| async function detach() { | ||||
| 	emit('detach'); | ||||
| 	dialog.value.close(); | ||||
| 	dialog.value?.close(); | ||||
| } | ||||
| </script> | ||||
|  | ||||
|   | ||||
| @@ -257,7 +257,7 @@ function parallaxLoop() { | ||||
| } | ||||
|  | ||||
| function parallax() { | ||||
| 	const banner = bannerEl.value as any; | ||||
| 	const banner = bannerEl.value; | ||||
| 	if (banner == null) return; | ||||
|  | ||||
| 	const top = getScrollPosition(rootEl.value); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 かっこかり
					かっこかり