fix code quality issues
This commit is contained in:
parent
9ffa56aa1b
commit
b6f6c3ea18
|
@ -9,9 +9,9 @@ import Channel, { type MiChannelService } from '../channel.js';
|
|||
|
||||
class AdminChannel extends Channel {
|
||||
public readonly chName = 'admin';
|
||||
public static shouldShare = true;
|
||||
public static requireCredential = true as const;
|
||||
public static kind = 'read:admin:stream';
|
||||
public static readonly shouldShare = true;
|
||||
public static readonly requireCredential = true as const;
|
||||
public static readonly kind = 'read:admin:stream';
|
||||
|
||||
@bindThis
|
||||
public async init(params: any) {
|
||||
|
|
|
@ -12,9 +12,9 @@ import Channel, { type MiChannelService } from '../channel.js';
|
|||
|
||||
class AntennaChannel extends Channel {
|
||||
public readonly chName = 'antenna';
|
||||
public static shouldShare = false;
|
||||
public static requireCredential = true as const;
|
||||
public static kind = 'read:account';
|
||||
public static readonly shouldShare = false;
|
||||
public static readonly requireCredential = true as const;
|
||||
public static readonly kind = 'read:account';
|
||||
private antennaId: string;
|
||||
|
||||
constructor(
|
||||
|
|
|
@ -12,8 +12,8 @@ import Channel, { type MiChannelService } from '../channel.js';
|
|||
|
||||
class ChannelChannel extends Channel {
|
||||
public readonly chName = 'channel';
|
||||
public static shouldShare = false;
|
||||
public static requireCredential = false as const;
|
||||
public static readonly shouldShare = false;
|
||||
public static readonly requireCredential = false as const;
|
||||
private channelId: string;
|
||||
|
||||
constructor(
|
||||
|
|
|
@ -9,9 +9,9 @@ import Channel, { type MiChannelService } from '../channel.js';
|
|||
|
||||
class DriveChannel extends Channel {
|
||||
public readonly chName = 'drive';
|
||||
public static shouldShare = true;
|
||||
public static requireCredential = true as const;
|
||||
public static kind = 'read:account';
|
||||
public static readonly shouldShare = true;
|
||||
public static readonly requireCredential = true as const;
|
||||
public static readonly kind = 'read:account';
|
||||
|
||||
@bindThis
|
||||
public async init(params: any) {
|
||||
|
|
|
@ -16,8 +16,8 @@ import Channel, { type MiChannelService } from '../channel.js';
|
|||
|
||||
class GlobalTimelineChannel extends Channel {
|
||||
public readonly chName = 'globalTimeline';
|
||||
public static shouldShare = false;
|
||||
public static requireCredential = false as const;
|
||||
public static readonly shouldShare = false;
|
||||
public static readonly requireCredential = false as const;
|
||||
private withRenotes: boolean;
|
||||
private withFiles: boolean;
|
||||
|
||||
|
|
|
@ -13,8 +13,8 @@ import Channel, { type MiChannelService } from '../channel.js';
|
|||
|
||||
class HashtagChannel extends Channel {
|
||||
public readonly chName = 'hashtag';
|
||||
public static shouldShare = false;
|
||||
public static requireCredential = false as const;
|
||||
public static readonly shouldShare = false;
|
||||
public static readonly requireCredential = false as const;
|
||||
private q: string[][];
|
||||
|
||||
constructor(
|
||||
|
|
|
@ -14,9 +14,9 @@ import Channel, { type MiChannelService } from '../channel.js';
|
|||
|
||||
class HomeTimelineChannel extends Channel {
|
||||
public readonly chName = 'homeTimeline';
|
||||
public static shouldShare = false;
|
||||
public static requireCredential = true as const;
|
||||
public static kind = 'read:account';
|
||||
public static readonly shouldShare = false;
|
||||
public static readonly requireCredential = true as const;
|
||||
public static readonly kind = 'read:account';
|
||||
private withRenotes: boolean;
|
||||
private withFiles: boolean;
|
||||
|
||||
|
|
|
@ -16,9 +16,9 @@ import Channel, { type MiChannelService } from '../channel.js';
|
|||
|
||||
class HybridTimelineChannel extends Channel {
|
||||
public readonly chName = 'hybridTimeline';
|
||||
public static shouldShare = false;
|
||||
public static requireCredential = true as const;
|
||||
public static kind = 'read:account';
|
||||
public static readonly shouldShare = false;
|
||||
public static readonly requireCredential = true as const;
|
||||
public static readonly kind = 'read:account';
|
||||
private withRenotes: boolean;
|
||||
private withReplies: boolean;
|
||||
private withFiles: boolean;
|
||||
|
|
|
@ -15,8 +15,8 @@ import Channel, { type MiChannelService } from '../channel.js';
|
|||
|
||||
class LocalTimelineChannel extends Channel {
|
||||
public readonly chName = 'localTimeline';
|
||||
public static shouldShare = false;
|
||||
public static requireCredential = false as const;
|
||||
public static readonly shouldShare = false;
|
||||
public static readonly requireCredential = false as const;
|
||||
private withRenotes: boolean;
|
||||
private withReplies: boolean;
|
||||
private withFiles: boolean;
|
||||
|
|
|
@ -11,9 +11,9 @@ import Channel, { type MiChannelService } from '../channel.js';
|
|||
|
||||
class MainChannel extends Channel {
|
||||
public readonly chName = 'main';
|
||||
public static shouldShare = true;
|
||||
public static requireCredential = true as const;
|
||||
public static kind = 'read:account';
|
||||
public static readonly shouldShare = true;
|
||||
public static readonly requireCredential = true as const;
|
||||
public static readonly kind = 'read:account';
|
||||
|
||||
constructor(
|
||||
private noteEntityService: NoteEntityService,
|
||||
|
|
|
@ -12,8 +12,8 @@ const ev = new Xev();
|
|||
|
||||
class QueueStatsChannel extends Channel {
|
||||
public readonly chName = 'queueStats';
|
||||
public static shouldShare = true;
|
||||
public static requireCredential = false as const;
|
||||
public static readonly shouldShare = true;
|
||||
public static readonly requireCredential = false as const;
|
||||
|
||||
constructor(id: string, connection: Channel['connection']) {
|
||||
super(id, connection);
|
||||
|
|
|
@ -13,8 +13,8 @@ import Channel, { type MiChannelService } from '../channel.js';
|
|||
|
||||
class ReversiGameChannel extends Channel {
|
||||
public readonly chName = 'reversiGame';
|
||||
public static shouldShare = false;
|
||||
public static requireCredential = false as const;
|
||||
public static readonly shouldShare = false;
|
||||
public static readonly requireCredential = false as const;
|
||||
private gameId: MiReversiGame['id'] | null = null;
|
||||
|
||||
constructor(
|
||||
|
|
|
@ -9,9 +9,9 @@ import Channel, { type MiChannelService } from '../channel.js';
|
|||
|
||||
class ReversiChannel extends Channel {
|
||||
public readonly chName = 'reversi';
|
||||
public static shouldShare = true;
|
||||
public static requireCredential = true as const;
|
||||
public static kind = 'read:account';
|
||||
public static readonly shouldShare = true;
|
||||
public static readonly requireCredential = true as const;
|
||||
public static readonly kind = 'read:account';
|
||||
|
||||
@bindThis
|
||||
public async init(params: any) {
|
||||
|
|
|
@ -14,8 +14,8 @@ import Channel, { type MiChannelService } from '../channel.js';
|
|||
|
||||
class RoleTimelineChannel extends Channel {
|
||||
public readonly chName = 'roleTimeline';
|
||||
public static shouldShare = false;
|
||||
public static requireCredential = false as const;
|
||||
public static readonly shouldShare = false;
|
||||
public static readonly requireCredential = false as const;
|
||||
private roleId: string;
|
||||
|
||||
constructor(
|
||||
|
|
|
@ -12,8 +12,8 @@ const ev = new Xev();
|
|||
|
||||
class ServerStatsChannel extends Channel {
|
||||
public readonly chName = 'serverStats';
|
||||
public static shouldShare = true;
|
||||
public static requireCredential = false as const;
|
||||
public static readonly shouldShare = true;
|
||||
public static readonly requireCredential = false as const;
|
||||
|
||||
constructor(id: string, connection: Channel['connection']) {
|
||||
super(id, connection);
|
||||
|
|
|
@ -15,8 +15,8 @@ import Channel, { type MiChannelService } from '../channel.js';
|
|||
|
||||
class UserListChannel extends Channel {
|
||||
public readonly chName = 'userList';
|
||||
public static shouldShare = false;
|
||||
public static requireCredential = false as const;
|
||||
public static readonly shouldShare = false;
|
||||
public static readonly requireCredential = false as const;
|
||||
private listId: string;
|
||||
private membershipsMap: Record<string, Pick<MiUserListMembership, 'withReplies'> | undefined> = {};
|
||||
private listUsersClock: NodeJS.Timeout;
|
||||
|
|
|
@ -47,12 +47,12 @@ onMounted(() => {
|
|||
const width = rootEl.value!.offsetWidth;
|
||||
const height = rootEl.value!.offsetHeight;
|
||||
|
||||
if (left + width - window.pageXOffset >= (window.innerWidth - SCROLLBAR_THICKNESS)) {
|
||||
left = (window.innerWidth - SCROLLBAR_THICKNESS) - width + window.pageXOffset;
|
||||
if (left + width - window.scrollX >= (window.innerWidth - SCROLLBAR_THICKNESS)) {
|
||||
left = (window.innerWidth - SCROLLBAR_THICKNESS) - width + window.scrollX;
|
||||
}
|
||||
|
||||
if (top + height - window.pageYOffset >= (window.innerHeight - SCROLLBAR_THICKNESS)) {
|
||||
top = (window.innerHeight - SCROLLBAR_THICKNESS) - height + window.pageYOffset;
|
||||
if (top + height - window.scrollY >= (window.innerHeight - SCROLLBAR_THICKNESS)) {
|
||||
top = (window.innerHeight - SCROLLBAR_THICKNESS) - height + window.scrollY;
|
||||
}
|
||||
|
||||
if (top < 0) {
|
||||
|
|
|
@ -212,14 +212,15 @@ const note = ref(deepClone(props.note));
|
|||
// plugin
|
||||
if (noteViewInterruptors.length > 0) {
|
||||
onMounted(async () => {
|
||||
let result: Misskey.entities.Note | null = deepClone(note.value);
|
||||
let result = deepClone(note.value);
|
||||
for (const interruptor of noteViewInterruptors) {
|
||||
try {
|
||||
result = await interruptor.handler(result!) as Misskey.entities.Note | null;
|
||||
if (result === null) {
|
||||
const r = await interruptor.handler(result) as Misskey.entities.Note | null;
|
||||
if (r === null) {
|
||||
isDeleted.value = true;
|
||||
return;
|
||||
}
|
||||
result = r;
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
|
|
|
@ -240,14 +240,15 @@ const note = ref(deepClone(props.note));
|
|||
// plugin
|
||||
if (noteViewInterruptors.length > 0) {
|
||||
onMounted(async () => {
|
||||
let result: Misskey.entities.Note | null = deepClone(note.value);
|
||||
let result = deepClone(note.value);
|
||||
for (const interruptor of noteViewInterruptors) {
|
||||
try {
|
||||
result = await interruptor.handler(result!) as Misskey.entities.Note | null;
|
||||
if (result === null) {
|
||||
const r = await interruptor.handler(result) as Misskey.entities.Note | null;
|
||||
if (r === null) {
|
||||
isDeleted.value = true;
|
||||
return;
|
||||
}
|
||||
result = r;
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
|
|
|
@ -72,9 +72,7 @@ export type PollEditorModelValue = {
|
|||
const props = defineProps<{
|
||||
modelValue: PollEditorModelValue;
|
||||
}>();
|
||||
const emit = defineEmits<{
|
||||
(ev: 'update:modelValue', v: PollEditorModelValue): void;
|
||||
}>();
|
||||
const emit = defineEmits<(ev: 'update:modelValue', v: PollEditorModelValue) => void>();
|
||||
|
||||
const choices = ref(props.modelValue.choices);
|
||||
const multiple = ref(props.modelValue.multiple);
|
||||
|
|
|
@ -352,7 +352,7 @@ if (props.specified) {
|
|||
}
|
||||
|
||||
// keep cw when reply
|
||||
if (defaultStore.state.keepCw && props.reply && props.reply.cw) {
|
||||
if (defaultStore.state.keepCw && props.reply?.cw) {
|
||||
useCw.value = true;
|
||||
cw.value = props.reply.cw;
|
||||
}
|
||||
|
@ -603,7 +603,7 @@ async function onPaste(ev: ClipboardEvent) {
|
|||
return;
|
||||
}
|
||||
|
||||
quoteId.value = paste.substring(url.length).match(/^\/notes\/(.+?)\/?$/)?.[1] ?? null;
|
||||
quoteId.value = RegExp(/^\/notes\/(.+?)\/?$/).exec(paste.substring(url.length))?.[1] ?? null;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -156,7 +156,7 @@ if (navigator.serviceWorker == null) {
|
|||
|
||||
pushSubscription.value = await registration.value.pushManager.getSubscription();
|
||||
|
||||
if (instance.swPublickey && ('PushManager' in window) && $i && $i.token) {
|
||||
if (instance.swPublickey && ('PushManager' in window) && $i?.token) {
|
||||
supported.value = true;
|
||||
|
||||
if (pushSubscription.value) {
|
||||
|
|
|
@ -142,7 +142,7 @@ async function queryKey(): Promise<void> {
|
|||
|
||||
function onSubmit(): void {
|
||||
signing.value = true;
|
||||
if (!totpLogin.value && user.value && user.value.twoFactorEnabled) {
|
||||
if (!totpLogin.value && user.value?.twoFactorEnabled) {
|
||||
if (webAuthnSupported() && user.value.securityKeys) {
|
||||
misskeyApi('signin', {
|
||||
username: username.value,
|
||||
|
|
|
@ -70,7 +70,7 @@ import { misskeyApi } from '@/scripts/misskey-api.js';
|
|||
import { defaultStore } from '@/store.js';
|
||||
import { i18n } from '@/i18n.js';
|
||||
import { $i } from '@/account.js';
|
||||
import { host as currentHost, hostname } from '@/config.js';
|
||||
import { hostname } from '@/config.js';
|
||||
|
||||
const emit = defineEmits<{
|
||||
(ev: 'ok', selected: Misskey.entities.UserDetailed): void;
|
||||
|
@ -138,8 +138,8 @@ onMounted(() => {
|
|||
return true;
|
||||
}
|
||||
});
|
||||
if (props.includeSelf && _users.find(x => $i ? x.id === $i.id : true) == null) {
|
||||
recentUsers.value = [$i!, ..._users];
|
||||
if (props.includeSelf && $i && !_users.find(x => $i ? x.id === $i.id : true)) {
|
||||
recentUsers.value = [$i, ..._users];
|
||||
} else {
|
||||
recentUsers.value = _users;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
<script lang="ts" setup>
|
||||
import { onMounted, shallowRef, ref, nextTick } from 'vue';
|
||||
import { Chart } from 'chart.js';
|
||||
import gradient from 'chartjs-plugin-gradient';
|
||||
import tinycolor from 'tinycolor2';
|
||||
import { misskeyApi } from '@/scripts/misskey-api.js';
|
||||
import { defaultStore } from '@/store.js';
|
||||
|
|
|
@ -62,12 +62,12 @@ export default function (props: MfmProps, { emit }: { emit: SetupContext<MfmEven
|
|||
const validTime = (t: string | boolean | null | undefined) => {
|
||||
if (t == null) return null;
|
||||
if (typeof t === 'boolean') return null;
|
||||
return t.match(/^[0-9.]+s$/) ? t : null;
|
||||
return RegExp(/^[0-9.]+s$/).exec(t) ? t : null;
|
||||
};
|
||||
|
||||
const validColor = (c: unknown): string | null => {
|
||||
if (typeof c !== 'string') return null;
|
||||
return c.match(/^[0-9a-f]{3,6}$/i) ? c : null;
|
||||
return RegExp(/^[0-9a-f]{3,6}$/i).exec(c) ? c : null;
|
||||
};
|
||||
|
||||
const useAnim = defaultStore.state.advancedMfm && defaultStore.state.animatedMfm;
|
||||
|
@ -356,7 +356,7 @@ export default function (props: MfmProps, { emit }: { emit: SetupContext<MfmEven
|
|||
case 'mention': {
|
||||
return [h(MkMention, {
|
||||
key: Math.random(),
|
||||
host: (token.props.host == null && props.author && props.author.host != null ? props.author.host : token.props.host) ?? host,
|
||||
host: (token.props.host == null && props.author?.host ? props.author.host : token.props.host) ?? host,
|
||||
username: token.props.username,
|
||||
})];
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ function onTabClick(t: Tab, ev: MouseEvent): void {
|
|||
|
||||
function renderTab() {
|
||||
const tabEl = props.tab ? tabRefs[props.tab] : undefined;
|
||||
if (tabEl && tabHighlightEl.value && tabHighlightEl.value.parentElement) {
|
||||
if (tabEl && tabHighlightEl.value?.parentElement) {
|
||||
// offsetWidth や offsetLeft は少数を丸めてしまうため getBoundingClientRect を使う必要がある
|
||||
// https://developer.mozilla.org/ja/docs/Web/API/HTMLElement/offsetWidth#%E5%80%A4
|
||||
const parentRect = tabHighlightEl.value.parentElement.getBoundingClientRect();
|
||||
|
|
Loading…
Reference in a new issue