fix lints in post-form-attaches and drive.file

This commit is contained in:
Norm 2022-08-31 07:01:03 -04:00
parent 157eab2dee
commit b712623aa4
Signed by untrusted user: norm
GPG key ID: 7123E30E441E80DE
2 changed files with 15 additions and 18 deletions

View file

@ -40,6 +40,7 @@ import bytes from '@/filters/bytes';
import * as os from '@/os'; import * as os from '@/os';
import { i18n } from '@/i18n'; import { i18n } from '@/i18n';
import { $i } from '@/account'; import { $i } from '@/account';
import { MenuItem } from '@/types/menu';
const props = withDefaults(defineProps<{ const props = withDefaults(defineProps<{
file: Misskey.entities.DriveFile; 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)}`); const title = computed(() => `${props.file.name}\n${props.file.type} ${bytes(props.file.size)}`);
function getMenu() { function getMenu(): MenuItem[] {
return [{ return [{
text: i18n.ts.rename, text: i18n.ts.rename,
icon: 'fas fa-i-cursor', icon: 'fas fa-i-cursor',
@ -92,7 +93,7 @@ function getMenu() {
}]; }];
} }
function onClick(ev: MouseEvent) { function onClick(ev: MouseEvent): void {
if (props.selectMode) { if (props.selectMode) {
emit('chosen', props.file); emit('chosen', props.file);
} else { } else {
@ -100,11 +101,11 @@ function onClick(ev: MouseEvent) {
} }
} }
function onContextmenu(ev: MouseEvent) { function onContextmenu(ev: MouseEvent): void {
os.contextMenu(getMenu(), ev); os.contextMenu(getMenu(), ev);
} }
function onDragstart(ev: DragEvent) { function onDragstart(ev: DragEvent): void {
if (ev.dataTransfer) { if (ev.dataTransfer) {
ev.dataTransfer.effectAllowed = 'move'; ev.dataTransfer.effectAllowed = 'move';
ev.dataTransfer.setData(_DATA_TRANSFER_DRIVE_FILE_, JSON.stringify(props.file)); ev.dataTransfer.setData(_DATA_TRANSFER_DRIVE_FILE_, JSON.stringify(props.file));
@ -114,12 +115,12 @@ function onDragstart(ev: DragEvent) {
emit('dragstart'); emit('dragstart');
} }
function onDragend() { function onDragend(): void {
isDragging.value = false; isDragging.value = false;
emit('dragend'); emit('dragend');
} }
function rename() { function rename(): void {
os.inputText({ os.inputText({
title: i18n.ts.renameFile, title: i18n.ts.renameFile,
placeholder: i18n.ts.inputNewFileName, placeholder: i18n.ts.inputNewFileName,
@ -133,12 +134,12 @@ function rename() {
}); });
} }
function describe() { function describe(): void {
os.popup(defineAsyncComponent(() => import('@/components/media-caption.vue')), { os.popup(defineAsyncComponent(() => import('@/components/media-caption.vue')), {
title: i18n.ts.describeFile, title: i18n.ts.describeFile,
input: { input: {
placeholder: i18n.ts.inputNewDescription, placeholder: i18n.ts.inputNewDescription,
default: props.file.comment != null ? props.file.comment : '', default: props.file.comment ?? '',
}, },
image: props.file, image: props.file,
}, { }, {
@ -153,23 +154,19 @@ function describe() {
}, 'closed'); }, 'closed');
} }
function toggleSensitive() { function toggleSensitive(): void {
os.api('drive/files/update', { os.api('drive/files/update', {
fileId: props.file.id, fileId: props.file.id,
isSensitive: !props.file.isSensitive, isSensitive: !props.file.isSensitive,
}); });
} }
function copyUrl() { function copyUrl(): void {
copyToClipboard(props.file.url); copyToClipboard(props.file.url);
os.success(); os.success();
} }
/*
function addApp() { async function deleteFile(): Promise<void> {
alert('not implemented yet');
}
*/
async function deleteFile() {
const { canceled } = await os.confirm({ const { canceled } = await os.confirm({
type: 'warning', type: 'warning',
text: i18n.t('driveFileDeleteConfirm', { name: props.file.name }), text: i18n.t('driveFileDeleteConfirm', { name: props.file.name }),

View file

@ -82,7 +82,7 @@ async function describe(file: DriveFile): Promise<void> {
title: i18n.ts.describeFile, title: i18n.ts.describeFile,
input: { input: {
placeholder: i18n.ts.inputNewDescription, placeholder: i18n.ts.inputNewDescription,
default: file.comment !== null ? file.comment : '', default: file.comment ?? '',
}, },
image: file, image: file,
}, { }, {
@ -117,7 +117,7 @@ function showFileMenu(file: DriveFile, ev: MouseEvent): void {
text: i18n.ts.attachCancel, text: i18n.ts.attachCancel,
icon: 'fas fa-times-circle', icon: 'fas fa-times-circle',
action: () => { detachMedia(file.id); }, action: () => { detachMedia(file.id); },
}], ev.currentTarget ?? ev.target).then(() => menu = null); }], ev.currentTarget as HTMLElement | null ?? ev.target as HTMLElement).then(() => menu = null);
} }
</script> </script>