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