refactor(frontend): reduce type errors

This commit is contained in:
syuilo 2024-01-05 12:52:24 +09:00
parent 9e20065496
commit 2177792a3c
4 changed files with 19 additions and 14 deletions

View file

@ -11,13 +11,13 @@ SPDX-License-Identifier: AGPL-3.0-only
:pagination="paginationQuery" :pagination="paginationQuery"
:noGap="!defaultStore.state.showGapBetweenNotesInTimeline" :noGap="!defaultStore.state.showGapBetweenNotesInTimeline"
@queue="emit('queue', $event)" @queue="emit('queue', $event)"
@status="prComponent.setDisabled($event)" @status="prComponent?.setDisabled($event)"
/> />
</MkPullToRefresh> </MkPullToRefresh>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { computed, watch, onUnmounted, provide, ref } from 'vue'; import { computed, watch, onUnmounted, provide, ref, shallowRef } from 'vue';
import { Connection } from 'misskey-js/built/streaming.js'; import { Connection } from 'misskey-js/built/streaming.js';
import MkNotes from '@/components/MkNotes.vue'; import MkNotes from '@/components/MkNotes.vue';
import MkPullToRefresh from '@/components/MkPullToRefresh.vue'; import MkPullToRefresh from '@/components/MkPullToRefresh.vue';
@ -62,12 +62,14 @@ type TimelineQueryType = {
roleId?: string roleId?: string
} }
const prComponent = ref<InstanceType<typeof MkPullToRefresh>>(); const prComponent = shallowRef<InstanceType<typeof MkPullToRefresh>>();
const tlComponent = ref<InstanceType<typeof MkNotes>>(); const tlComponent = shallowRef<InstanceType<typeof MkNotes>>();
let tlNotesCount = 0; let tlNotesCount = 0;
const prepend = note => { function prepend(note) {
if (tlComponent.value == null) return;
tlNotesCount++; tlNotesCount++;
if (instance.notesPerOneAd > 0 && tlNotesCount % instance.notesPerOneAd === 0) { if (instance.notesPerOneAd > 0 && tlNotesCount % instance.notesPerOneAd === 0) {
@ -81,7 +83,7 @@ const prepend = note => {
if (props.sound) { if (props.sound) {
sound.play($i && (note.userId === $i.id) ? 'noteMy' : 'note'); sound.play($i && (note.userId === $i.id) ? 'noteMy' : 'note');
} }
}; }
let connection: Connection; let connection: Connection;
let connection2: Connection; let connection2: Connection;
@ -246,6 +248,8 @@ onUnmounted(() => {
function reloadTimeline() { function reloadTimeline() {
return new Promise<void>((res) => { return new Promise<void>((res) => {
if (tlComponent.value == null) return;
tlNotesCount = 0; tlNotesCount = 0;
tlComponent.value.pagingComponent?.reload().then(() => { tlComponent.value.pagingComponent?.reload().then(() => {

View file

@ -11,7 +11,7 @@ SPDX-License-Identifier: AGPL-3.0-only
:withOkButton="true" :withOkButton="true"
:okButtonDisabled="false" :okButtonDisabled="false"
:canClose="false" :canClose="false"
@close="dialog.close()" @close="dialog?.close()"
@closed="$emit('closed')" @closed="$emit('closed')"
@ok="ok()" @ok="ok()"
> >
@ -87,7 +87,7 @@ function ok(): void {
name: name.value, name: name.value,
permissions: Object.keys(permissions.value).filter(p => permissions.value[p]), permissions: Object.keys(permissions.value).filter(p => permissions.value[p]),
}); });
dialog.value.close(); dialog.value?.close();
} }
function disableAll(): void { function disableAll(): void {

View file

@ -31,7 +31,7 @@ const props = withDefaults(defineProps<{
targetElement?: HTMLElement; targetElement?: HTMLElement;
x?: number; x?: number;
y?: number; y?: number;
text?: string; text: string;
asMfm?: boolean; asMfm?: boolean;
maxWidth?: number; maxWidth?: number;
direction?: 'top' | 'bottom' | 'right' | 'left'; direction?: 'top' | 'bottom' | 'right' | 'left';
@ -53,6 +53,7 @@ const el = shallowRef<HTMLElement>();
const zIndex = os.claimZIndex('high'); const zIndex = os.claimZIndex('high');
function setPosition() { function setPosition() {
if (!el.value || !props.targetElement) return;
const data = calcPopupPosition(el.value, { const data = calcPopupPosition(el.value, {
anchorElement: props.targetElement, anchorElement: props.targetElement,
direction: props.direction, direction: props.direction,

View file

@ -4,12 +4,12 @@ SPDX-License-Identifier: AGPL-3.0-only
--> -->
<template> <template>
<MkModal ref="modal" :zPriority="'middle'" @click="$refs.modal.close()" @closed="$emit('closed')"> <MkModal ref="modal" :zPriority="'middle'" @click="modal?.close()" @closed="$emit('closed')">
<div :class="$style.root"> <div :class="$style.root">
<div :class="$style.title"><MkSparkle>{{ i18n.ts.misskeyUpdated }}</MkSparkle></div> <div :class="$style.title"><MkSparkle>{{ i18n.ts.misskeyUpdated }}</MkSparkle></div>
<div :class="$style.version">{{ version }}🚀</div> <div :class="$style.version">{{ version }}🚀</div>
<MkButton full @click="whatIsNew">{{ i18n.ts.whatIsNew }}</MkButton> <MkButton full @click="whatIsNew">{{ i18n.ts.whatIsNew }}</MkButton>
<MkButton :class="$style.gotIt" primary full @click="$refs.modal.close()">{{ i18n.ts.gotIt }}</MkButton> <MkButton :class="$style.gotIt" primary full @click="modal?.close()">{{ i18n.ts.gotIt }}</MkButton>
</div> </div>
</MkModal> </MkModal>
</template> </template>
@ -25,10 +25,10 @@ import { confetti } from '@/scripts/confetti.js';
const modal = shallowRef<InstanceType<typeof MkModal>>(); const modal = shallowRef<InstanceType<typeof MkModal>>();
const whatIsNew = () => { function whatIsNew() {
modal.value.close(); modal.value?.close();
window.open(`https://misskey-hub.net/docs/releases/#_${version.replace(/\./g, '')}`, '_blank'); window.open(`https://misskey-hub.net/docs/releases/#_${version.replace(/\./g, '')}`, '_blank');
}; }
onMounted(() => { onMounted(() => {
confetti({ confetti({