From b712623aa4e139137af298491e469766b07e86ce Mon Sep 17 00:00:00 2001 From: Francis Dinh Date: Wed, 31 Aug 2022 07:01:03 -0400 Subject: [PATCH] fix lints in post-form-attaches and drive.file --- packages/client/src/components/drive.file.vue | 29 +++++++++---------- .../src/components/post-form-attaches.vue | 4 +-- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/packages/client/src/components/drive.file.vue b/packages/client/src/components/drive.file.vue index 1d94b6782..268c79bcf 100644 --- a/packages/client/src/components/drive.file.vue +++ b/packages/client/src/components/drive.file.vue @@ -40,6 +40,7 @@ import bytes from '@/filters/bytes'; import * as os from '@/os'; import { i18n } from '@/i18n'; import { $i } from '@/account'; +import { MenuItem } from '@/types/menu'; const props = withDefaults(defineProps<{ file: Misskey.entities.DriveFile; @@ -60,7 +61,7 @@ const isDragging = ref(false); const title = computed(() => `${props.file.name}\n${props.file.type} ${bytes(props.file.size)}`); -function getMenu() { +function getMenu(): MenuItem[] { return [{ text: i18n.ts.rename, icon: 'fas fa-i-cursor', @@ -92,7 +93,7 @@ function getMenu() { }]; } -function onClick(ev: MouseEvent) { +function onClick(ev: MouseEvent): void { if (props.selectMode) { emit('chosen', props.file); } else { @@ -100,11 +101,11 @@ function onClick(ev: MouseEvent) { } } -function onContextmenu(ev: MouseEvent) { +function onContextmenu(ev: MouseEvent): void { os.contextMenu(getMenu(), ev); } -function onDragstart(ev: DragEvent) { +function onDragstart(ev: DragEvent): void { if (ev.dataTransfer) { ev.dataTransfer.effectAllowed = 'move'; ev.dataTransfer.setData(_DATA_TRANSFER_DRIVE_FILE_, JSON.stringify(props.file)); @@ -114,12 +115,12 @@ function onDragstart(ev: DragEvent) { emit('dragstart'); } -function onDragend() { +function onDragend(): void { isDragging.value = false; emit('dragend'); } -function rename() { +function rename(): void { os.inputText({ title: i18n.ts.renameFile, placeholder: i18n.ts.inputNewFileName, @@ -133,12 +134,12 @@ function rename() { }); } -function describe() { +function describe(): void { os.popup(defineAsyncComponent(() => import('@/components/media-caption.vue')), { title: i18n.ts.describeFile, input: { placeholder: i18n.ts.inputNewDescription, - default: props.file.comment != null ? props.file.comment : '', + default: props.file.comment ?? '', }, image: props.file, }, { @@ -153,23 +154,19 @@ function describe() { }, 'closed'); } -function toggleSensitive() { +function toggleSensitive(): void { os.api('drive/files/update', { fileId: props.file.id, isSensitive: !props.file.isSensitive, }); } -function copyUrl() { +function copyUrl(): void { copyToClipboard(props.file.url); os.success(); } -/* -function addApp() { - alert('not implemented yet'); -} -*/ -async function deleteFile() { + +async function deleteFile(): Promise { const { canceled } = await os.confirm({ type: 'warning', text: i18n.t('driveFileDeleteConfirm', { name: props.file.name }), diff --git a/packages/client/src/components/post-form-attaches.vue b/packages/client/src/components/post-form-attaches.vue index 77051cdae..fdf6fdbe7 100644 --- a/packages/client/src/components/post-form-attaches.vue +++ b/packages/client/src/components/post-form-attaches.vue @@ -82,7 +82,7 @@ async function describe(file: DriveFile): Promise { title: i18n.ts.describeFile, input: { placeholder: i18n.ts.inputNewDescription, - default: file.comment !== null ? file.comment : '', + default: file.comment ?? '', }, image: file, }, { @@ -117,7 +117,7 @@ function showFileMenu(file: DriveFile, ev: MouseEvent): void { text: i18n.ts.attachCancel, icon: 'fas fa-times-circle', action: () => { detachMedia(file.id); }, - }], ev.currentTarget ?? ev.target).then(() => menu = null); + }], ev.currentTarget as HTMLElement | null ?? ev.target as HTMLElement).then(() => menu = null); }