* fix: emits use ev instead of e

* fix: errors use err instead of e

* fix: replace use of data where possible

* fix: events use evt instead of e

* fix: use strict equals

* fix: use emoji instead of e

* fix: vue lints
This commit is contained in:
Johann150 2022-05-26 15:53:09 +02:00 committed by GitHub
parent 8d49573447
commit d2ca085a17
69 changed files with 255 additions and 257 deletions

View file

@ -11,10 +11,10 @@ import { i18n } from './i18n';
type Account = misskey.entities.MeDetailed; type Account = misskey.entities.MeDetailed;
const data = localStorage.getItem('account'); const accountData = localStorage.getItem('account');
// TODO: 外部からはreadonlyに // TODO: 外部からはreadonlyに
export const $i = data ? reactive(JSON.parse(data) as Account) : null; export const $i = accountData ? reactive(JSON.parse(accountData) as Account) : null;
export const iAmModerator = $i != null && ($i.isAdmin || $i.isModerator); export const iAmModerator = $i != null && ($i.isAdmin || $i.isModerator);
@ -52,7 +52,7 @@ export async function signout() {
return Promise.all(registrations.map(registration => registration.unregister())); return Promise.all(registrations.map(registration => registration.unregister()));
}); });
} }
} catch (e) {} } catch (err) {}
//#endregion //#endregion
document.cookie = `igi=; path=/`; document.cookie = `igi=; path=/`;
@ -104,8 +104,8 @@ function fetchAccount(token: string): Promise<Account> {
}); });
} }
export function updateAccount(data) { export function updateAccount(accountData) {
for (const [key, value] of Object.entries(data)) { for (const [key, value] of Object.entries(accountData)) {
$i[key] = value; $i[key] = value;
} }
localStorage.setItem('account', JSON.stringify($i)); localStorage.setItem('account', JSON.stringify($i));

View file

@ -37,7 +37,7 @@ const props = defineProps<{
}>(); }>();
const emit = defineEmits<{ const emit = defineEmits<{
(e: 'closed'): void; (ev: 'closed'): void;
}>(); }>();
const window = ref<InstanceType<typeof XWindow>>(); const window = ref<InstanceType<typeof XWindow>>();

View file

@ -2,7 +2,7 @@
<div class="bcekxzvu _card _gap"> <div class="bcekxzvu _card _gap">
<div class="_content target"> <div class="_content target">
<MkAvatar class="avatar" :user="report.targetUser" :show-indicator="true"/> <MkAvatar class="avatar" :user="report.targetUser" :show-indicator="true"/>
<MkA class="info" :to="userPage(report.targetUser)" v-user-preview="report.targetUserId"> <MkA v-user-preview="report.targetUserId" class="info" :to="userPage(report.targetUser)">
<MkUserName class="name" :user="report.targetUser"/> <MkUserName class="name" :user="report.targetUser"/>
<MkAcct class="acct" :user="report.targetUser" style="display: block;"/> <MkAcct class="acct" :user="report.targetUser" style="display: block;"/>
</MkA> </MkA>

View file

@ -48,8 +48,8 @@ async function onClick() {
}); });
isFollowing.value = true; isFollowing.value = true;
} }
} catch (e) { } catch (err) {
console.error(e); console.error(err);
} finally { } finally {
wait.value = false; wait.value = false;
} }

View file

@ -18,7 +18,7 @@ const props = defineProps<{
}>(); }>();
const emit = defineEmits<{ const emit = defineEmits<{
(e: 'update:modelValue', v: boolean): void; (ev: 'update:modelValue', v: boolean): void;
}>(); }>();
const label = computed(() => { const label = computed(() => {

View file

@ -90,8 +90,8 @@ const props = withDefaults(defineProps<{
}); });
const emit = defineEmits<{ const emit = defineEmits<{
(e: 'done', v: { canceled: boolean; result: any }): void; (ev: 'done', v: { canceled: boolean; result: any }): void;
(e: 'closed'): void; (ev: 'closed'): void;
}>(); }>();
const modal = ref<InstanceType<typeof MkModal>>(); const modal = ref<InstanceType<typeof MkModal>>();
@ -122,14 +122,14 @@ function onBgClick() {
if (props.cancelableByBgClick) cancel(); if (props.cancelableByBgClick) cancel();
} }
*/ */
function onKeydown(e: KeyboardEvent) { function onKeydown(evt: KeyboardEvent) {
if (e.key === 'Escape') cancel(); if (evt.key === 'Escape') cancel();
} }
function onInputKeydown(e: KeyboardEvent) { function onInputKeydown(evt: KeyboardEvent) {
if (e.key === 'Enter') { if (evt.key === 'Enter') {
e.preventDefault(); evt.preventDefault();
e.stopPropagation(); evt.stopPropagation();
ok(); ok();
} }
} }

View file

@ -58,7 +58,7 @@ if (props.user.isFollowing == null) {
} }
function onFollowChange(user: Misskey.entities.UserDetailed) { function onFollowChange(user: Misskey.entities.UserDetailed) {
if (user.id == props.user.id) { if (user.id === props.user.id) {
isFollowing.value = user.isFollowing; isFollowing.value = user.isFollowing;
hasPendingFollowRequestFromYou.value = user.hasPendingFollowRequestFromYou; hasPendingFollowRequestFromYou.value = user.hasPendingFollowRequestFromYou;
} }
@ -96,8 +96,8 @@ async function onClick() {
hasPendingFollowRequestFromYou.value = true; hasPendingFollowRequestFromYou.value = true;
} }
} }
} catch (e) { } catch (err) {
console.error(e); console.error(err);
} finally { } finally {
wait.value = false; wait.value = false;
} }

View file

@ -41,8 +41,8 @@ import { instance } from '@/instance';
import { i18n } from '@/i18n'; import { i18n } from '@/i18n';
const emit = defineEmits<{ const emit = defineEmits<{
(e: 'done'): void; (ev: 'done'): void;
(e: 'closed'): void; (ev: 'closed'): void;
}>(); }>();
let dialog: InstanceType<typeof XModalWindow> = $ref(); let dialog: InstanceType<typeof XModalWindow> = $ref();

View file

@ -44,7 +44,7 @@
<template #label><span v-text="form[item].label || item"></span><span v-if="form[item].required === false"> ({{ $ts.optional }})</span></template> <template #label><span v-text="form[item].label || item"></span><span v-if="form[item].required === false"> ({{ $ts.optional }})</span></template>
<template v-if="form[item].description" #caption>{{ form[item].description }}</template> <template v-if="form[item].description" #caption>{{ form[item].description }}</template>
</FormRange> </FormRange>
<MkButton v-else-if="form[item].type === 'button'" @click="form[item].action($event, values)" class="_formBlock"> <MkButton v-else-if="form[item].type === 'button'" class="_formBlock" @click="form[item].action($event, values)">
<span v-text="form[item].content || item"></span> <span v-text="form[item].content || item"></span>
</MkButton> </MkButton>
</template> </template>

View file

@ -31,7 +31,7 @@ const props = defineProps<{
}>(); }>();
const emit = defineEmits<{ const emit = defineEmits<{
(e: 'update:modelValue', v: boolean): void; (ev: 'update:modelValue', v: boolean): void;
}>(); }>();
let button = $ref<HTMLElement>(); let button = $ref<HTMLElement>();

View file

@ -32,7 +32,7 @@ const props = withDefaults(defineProps<{
}); });
const emit = defineEmits<{ const emit = defineEmits<{
(e: 'click', ev: MouseEvent): void; (ev: 'click', v: MouseEvent): void;
}>(); }>();
const url = $computed(() => defaultStore.state.disableShowingAnimatedImages const url = $computed(() => defaultStore.state.disableShowingAnimatedImages

View file

@ -46,7 +46,7 @@ export default defineComponent({
const url = computed(() => { const url = computed(() => {
if (char.value) { if (char.value) {
let codes = Array.from(char.value).map(x => x.codePointAt(0).toString(16)); let codes = Array.from(char.value).map(x => x.codePointAt(0).toString(16));
if (!codes.includes('200d')) codes = codes.filter(x => x != 'fe0f'); if (!codes.includes('200d')) codes = codes.filter(x => x !== 'fe0f');
codes = codes.filter(x => x && x.length); codes = codes.filter(x => x && x.length);
return `${twemojiSvgBase}/${codes.join('-')}.svg`; return `${twemojiSvgBase}/${codes.join('-')}.svg`;
} else { } else {

View file

@ -17,7 +17,7 @@ const props = withDefaults(defineProps<{
mode: 'relative', mode: 'relative',
}); });
const _time = typeof props.time == 'string' ? new Date(props.time) : props.time; const _time = typeof props.time === 'string' ? new Date(props.time) : props.time;
const absolute = _time.toLocaleString(); const absolute = _time.toLocaleString();
let now = $ref(new Date()); let now = $ref(new Date());

View file

@ -25,7 +25,7 @@ const props = withDefaults(defineProps<{
}); });
const emit = defineEmits<{ const emit = defineEmits<{
(e: 'closed'): void; (ev: 'closed'): void;
}>(); }>();
const modal = $ref<InstanceType<typeof MkModal>>(); const modal = $ref<InstanceType<typeof MkModal>>();

View file

@ -77,7 +77,7 @@ export default defineComponent({
computed: { computed: {
remainingLength(): number { remainingLength(): number {
if (typeof this.inputValue != "string") return 512; if (typeof this.inputValue !== "string") return 512;
return 512 - length(this.inputValue); return 512 - length(this.inputValue);
} }
}, },
@ -116,17 +116,17 @@ export default defineComponent({
} }
}, },
onKeydown(e) { onKeydown(evt) {
if (e.which === 27) { // ESC if (evt.which === 27) { // ESC
this.cancel(); this.cancel();
} }
}, },
onInputKeydown(e) { onInputKeydown(evt) {
if (e.which === 13) { // Enter if (evt.which === 13) { // Enter
if (e.ctrlKey) { if (evt.ctrlKey) {
e.preventDefault(); evt.preventDefault();
e.stopPropagation(); evt.stopPropagation();
this.ok(); this.ok();
} }
} }

View file

@ -2,9 +2,9 @@
<div <div
v-if="!muted" v-if="!muted"
v-show="!isDeleted" v-show="!isDeleted"
ref="el"
v-hotkey="keymap" v-hotkey="keymap"
v-size="{ max: [500, 450, 350, 300] }" v-size="{ max: [500, 450, 350, 300] }"
ref="el"
class="lxwezrsl _block" class="lxwezrsl _block"
:tabindex="!isDeleted ? '-1' : null" :tabindex="!isDeleted ? '-1' : null"
:class="{ renote: isRenote }" :class="{ renote: isRenote }"
@ -197,7 +197,7 @@ const keymap = {
'q': () => renoteButton.value.renote(true), 'q': () => renoteButton.value.renote(true),
'esc': blur, 'esc': blur,
'm|o': () => menu(true), 'm|o': () => menu(true),
's': () => showContent.value != showContent.value, 's': () => showContent.value !== showContent.value,
}; };
useNoteCapture({ useNoteCapture({

View file

@ -185,7 +185,7 @@ const keymap = {
'down|j|tab': focusAfter, 'down|j|tab': focusAfter,
'esc': blur, 'esc': blur,
'm|o': () => menu(true), 'm|o': () => menu(true),
's': () => showContent.value != showContent.value, 's': () => showContent.value !== showContent.value,
}; };
useNoteCapture({ useNoteCapture({

View file

@ -52,16 +52,16 @@ export default defineComponent({
const promise = new Promise((ok) => { const promise = new Promise((ok) => {
const canvas = this.hpml.canvases[this.block.canvasId]; const canvas = this.hpml.canvases[this.block.canvasId];
canvas.toBlob(blob => { canvas.toBlob(blob => {
const data = new FormData(); const formData = new FormData();
data.append('file', blob); formData.append('file', blob);
data.append('i', this.$i.token); formData.append('i', this.$i.token);
if (this.$store.state.uploadFolder) { if (this.$store.state.uploadFolder) {
data.append('folderId', this.$store.state.uploadFolder); formData.append('folderId', this.$store.state.uploadFolder);
} }
fetch(apiUrl + '/drive/files/create', { fetch(apiUrl + '/drive/files/create', {
method: 'POST', method: 'POST',
body: data body: formData,
}) })
.then(response => response.json()) .then(response => response.json())
.then(f => { .then(f => {

View file

@ -38,8 +38,8 @@ export default defineComponent({
let ast; let ast;
try { try {
ast = parse(props.page.script); ast = parse(props.page.script);
} catch (e) { } catch (err) {
console.error(e); console.error(err);
/*os.alert({ /*os.alert({
type: 'error', type: 'error',
text: 'Syntax error :(' text: 'Syntax error :('
@ -48,11 +48,11 @@ export default defineComponent({
} }
hpml.aiscript.exec(ast).then(() => { hpml.aiscript.exec(ast).then(() => {
hpml.eval(); hpml.eval();
}).catch(e => { }).catch(err => {
console.error(e); console.error(err);
/*os.alert({ /*os.alert({
type: 'error', type: 'error',
text: e text: err
});*/ });*/
}); });
} else { } else {

View file

@ -104,7 +104,7 @@ function add() {
} }
function remove(i) { function remove(i) {
choices.value = choices.value.filter((_, _i) => _i != i); choices.value = choices.value.filter((_, _i) => _i !== i);
} }
function get() { function get() {

View file

@ -98,7 +98,7 @@ export default defineComponent({
}, { }, {
done: result => { done: result => {
if (!result || result.canceled) return; if (!result || result.canceled) return;
let comment = result.result.length == 0 ? null : result.result; let comment = result.result.length === 0 ? null : result.result;
os.api('drive/files/update', { os.api('drive/files/update', {
fileId: file.id, fileId: file.id,
comment: comment, comment: comment,

View file

@ -107,7 +107,7 @@ const props = withDefaults(defineProps<{
fixed?: boolean; fixed?: boolean;
autofocus?: boolean; autofocus?: boolean;
}>(), { }>(), {
initialVisibleUsers: [], initialVisibleUsers: () => [],
autofocus: true, autofocus: true,
}); });

View file

@ -27,8 +27,8 @@ const props = withDefaults(defineProps<{
}); });
const emit = defineEmits<{ const emit = defineEmits<{
(e: 'done'): void; (ev: 'done'): void;
(e: 'closed'): void; (ev: 'closed'): void;
}>(); }>();
const dialog = $ref<InstanceType<typeof XModalWindow>>(); const dialog = $ref<InstanceType<typeof XModalWindow>>();

View file

@ -124,20 +124,20 @@ export default defineComponent({
this.meta.tosUrl && !this.ToSAgreement || this.meta.tosUrl && !this.ToSAgreement ||
this.meta.enableHcaptcha && !this.hCaptchaResponse || this.meta.enableHcaptcha && !this.hCaptchaResponse ||
this.meta.enableRecaptcha && !this.reCaptchaResponse || this.meta.enableRecaptcha && !this.reCaptchaResponse ||
this.passwordRetypeState == 'not-match'; this.passwordRetypeState === 'not-match';
}, },
shouldShowProfileUrl(): boolean { shouldShowProfileUrl(): boolean {
return (this.username != '' && return (this.username !== '' &&
this.usernameState != 'invalid-format' && this.usernameState !== 'invalid-format' &&
this.usernameState != 'min-range' && this.usernameState !== 'min-range' &&
this.usernameState != 'max-range'); this.usernameState !== 'max-range');
} }
}, },
methods: { methods: {
onChangeUsername() { onChangeUsername() {
if (this.username == '') { if (this.username === '') {
this.usernameState = null; this.usernameState = null;
return; return;
} }
@ -165,7 +165,7 @@ export default defineComponent({
}, },
onChangeEmail() { onChangeEmail() {
if (this.email == '') { if (this.email === '') {
this.emailState = null; this.emailState = null;
return; return;
} }
@ -188,7 +188,7 @@ export default defineComponent({
}, },
onChangePassword() { onChangePassword() {
if (this.password == '') { if (this.password === '') {
this.passwordStrength = ''; this.passwordStrength = '';
return; return;
} }
@ -198,12 +198,12 @@ export default defineComponent({
}, },
onChangePasswordRetype() { onChangePasswordRetype() {
if (this.retypedPassword == '') { if (this.retypedPassword === '') {
this.passwordRetypeState = null; this.passwordRetypeState = null;
return; return;
} }
this.passwordRetypeState = this.password == this.retypedPassword ? 'match' : 'not-match'; this.passwordRetypeState = this.password === this.retypedPassword ? 'match' : 'not-match';
}, },
onSubmit() { onSubmit() {

View file

@ -19,8 +19,8 @@ const props = defineProps<{
}>(); }>();
const emit = defineEmits<{ const emit = defineEmits<{
(e: 'note'): void; (ev: 'note'): void;
(e: 'queue', count: number): void; (ev: 'queue', count: number): void;
}>(); }>();
provide('inChannel', computed(() => props.src === 'channel')); provide('inChannel', computed(() => props.src === 'channel'));
@ -95,7 +95,7 @@ if (props.src === 'antenna') {
visibility: 'specified' visibility: 'specified'
}; };
const onNote = note => { const onNote = note => {
if (note.visibility == 'specified') { if (note.visibility === 'specified') {
prepend(note); prepend(note);
} }
}; };

View file

@ -19,7 +19,7 @@ defineProps<{
}>(); }>();
const emit = defineEmits<{ const emit = defineEmits<{
(e: 'closed'): void; (ev: 'closed'): void;
}>(); }>();
const zIndex = os.claimZIndex('high'); const zIndex = os.claimZIndex('high');

View file

@ -90,7 +90,7 @@ export default defineComponent({
} }
}, },
methods: { methods: {
onMousedown(e: MouseEvent) { onMousedown(evt: MouseEvent) {
function distance(p, q) { function distance(p, q) {
return Math.hypot(p.x - q.x, p.y - q.y); return Math.hypot(p.x - q.x, p.y - q.y);
} }
@ -104,18 +104,18 @@ export default defineComponent({
return Math.max(dist1, dist2, dist3, dist4) * 2; return Math.max(dist1, dist2, dist3, dist4) * 2;
} }
const rect = e.target.getBoundingClientRect(); const rect = evt.target.getBoundingClientRect();
const ripple = document.createElement('div'); const ripple = document.createElement('div');
ripple.style.top = (e.clientY - rect.top - 1).toString() + 'px'; ripple.style.top = (evt.clientY - rect.top - 1).toString() + 'px';
ripple.style.left = (e.clientX - rect.left - 1).toString() + 'px'; ripple.style.left = (evt.clientX - rect.left - 1).toString() + 'px';
this.$refs.ripples.appendChild(ripple); this.$refs.ripples.appendChild(ripple);
const circleCenterX = e.clientX - rect.left; const circleCenterX = evt.clientX - rect.left;
const circleCenterY = e.clientY - rect.top; const circleCenterY = evt.clientY - rect.top;
const scale = calcCircleScale(e.target.clientWidth, e.target.clientHeight, circleCenterX, circleCenterY); const scale = calcCircleScale(evt.target.clientWidth, evt.target.clientHeight, circleCenterX, circleCenterY);
window.setTimeout(() => { window.setTimeout(() => {
ripple.style.transform = 'scale(' + (scale / 2) + ')'; ripple.style.transform = 'scale(' + (scale / 2) + ')';

View file

@ -19,7 +19,7 @@ const props = defineProps<{
}>(); }>();
const emit = defineEmits<{ const emit = defineEmits<{
(e: 'closed'): void; (ev: 'closed'): void;
}>(); }>();
let rootEl = $ref<HTMLDivElement>(); let rootEl = $ref<HTMLDivElement>();
@ -63,8 +63,8 @@ onBeforeUnmount(() => {
} }
}); });
function onMousedown(e: Event) { function onMousedown(evt: Event) {
if (!contains(rootEl, e.target) && (rootEl != e.target)) emit('closed'); if (!contains(rootEl, evt.target) && (rootEl !== evt.target)) emit('closed');
} }
</script> </script>

View file

@ -60,7 +60,7 @@ const props = defineProps<{
}>(); }>();
const emit = defineEmits<{ const emit = defineEmits<{
(e: 'close'): void; (ev: 'close'): void;
}>(); }>();
let itemsEl = $ref<HTMLDivElement>(); let itemsEl = $ref<HTMLDivElement>();

View file

@ -79,10 +79,10 @@ export default defineComponent({
this.$refs.modal.close(); this.$refs.modal.close();
}, },
onKeydown(e) { onKeydown(evt) {
if (e.which === 27) { // Esc if (evt.which === 27) { // Esc
e.preventDefault(); evt.preventDefault();
e.stopPropagation(); evt.stopPropagation();
this.close(); this.close();
} }
}, },

View file

@ -68,7 +68,7 @@ const props = withDefaults(defineProps<{
}); });
const emit = defineEmits<{ const emit = defineEmits<{
(e: 'queue', count: number): void; (ev: 'queue', count: number): void;
}>(); }>();
type Item = { id: string; [another: string]: unknown; }; type Item = { id: string; [another: string]: unknown; };
@ -112,7 +112,7 @@ const init = async (): Promise<void> => {
offset.value = res.length; offset.value = res.length;
error.value = false; error.value = false;
fetching.value = false; fetching.value = false;
}, e => { }, err => {
error.value = true; error.value = true;
fetching.value = false; fetching.value = false;
}); });
@ -155,7 +155,7 @@ const fetchMore = async (): Promise<void> => {
} }
offset.value += res.length; offset.value += res.length;
moreFetching.value = false; moreFetching.value = false;
}, e => { }, err => {
moreFetching.value = false; moreFetching.value = false;
}); });
}; };
@ -183,7 +183,7 @@ const fetchMoreAhead = async (): Promise<void> => {
} }
offset.value += res.length; offset.value += res.length;
moreFetching.value = false; moreFetching.value = false;
}, e => { }, err => {
moreFetching.value = false; moreFetching.value = false;
}); });
}; };

View file

@ -19,7 +19,7 @@ defineProps<{
}>(); }>();
const emit = defineEmits<{ const emit = defineEmits<{
(e: 'closed'): void; (ev: 'closed'): void;
}>(); }>();
let modal = $ref<InstanceType<typeof MkModal>>(); let modal = $ref<InstanceType<typeof MkModal>>();

View file

@ -139,10 +139,10 @@ export default defineComponent({
this.showing = false; this.showing = false;
}, },
onKeydown(e) { onKeydown(evt) {
if (e.which === 27) { // Esc if (evt.which === 27) { // Esc
e.preventDefault(); evt.preventDefault();
e.stopPropagation(); evt.stopPropagation();
this.close(); this.close();
} }
}, },
@ -162,15 +162,15 @@ export default defineComponent({
this.top(); this.top();
}, },
onHeaderMousedown(e) { onHeaderMousedown(evt) {
const main = this.$el as any; const main = this.$el as any;
if (!contains(main, document.activeElement)) main.focus(); if (!contains(main, document.activeElement)) main.focus();
const position = main.getBoundingClientRect(); const position = main.getBoundingClientRect();
const clickX = e.touches && e.touches.length > 0 ? e.touches[0].clientX : e.clientX; const clickX = evt.touches && evt.touches.length > 0 ? evt.touches[0].clientX : evt.clientX;
const clickY = e.touches && e.touches.length > 0 ? e.touches[0].clientY : e.clientY; const clickY = evt.touches && evt.touches.length > 0 ? evt.touches[0].clientY : evt.clientY;
const moveBaseX = clickX - position.left; const moveBaseX = clickX - position.left;
const moveBaseY = clickY - position.top; const moveBaseY = clickY - position.top;
const browserWidth = window.innerWidth; const browserWidth = window.innerWidth;
@ -204,10 +204,10 @@ export default defineComponent({
}, },
// //
onTopHandleMousedown(e) { onTopHandleMousedown(evt) {
const main = this.$el as any; const main = this.$el as any;
const base = e.clientY; const base = evt.clientY;
const height = parseInt(getComputedStyle(main, '').height, 10); const height = parseInt(getComputedStyle(main, '').height, 10);
const top = parseInt(getComputedStyle(main, '').top, 10); const top = parseInt(getComputedStyle(main, '').top, 10);
@ -230,10 +230,10 @@ export default defineComponent({
}, },
// //
onRightHandleMousedown(e) { onRightHandleMousedown(evt) {
const main = this.$el as any; const main = this.$el as any;
const base = e.clientX; const base = evt.clientX;
const width = parseInt(getComputedStyle(main, '').width, 10); const width = parseInt(getComputedStyle(main, '').width, 10);
const left = parseInt(getComputedStyle(main, '').left, 10); const left = parseInt(getComputedStyle(main, '').left, 10);
const browserWidth = window.innerWidth; const browserWidth = window.innerWidth;
@ -254,10 +254,10 @@ export default defineComponent({
}, },
// //
onBottomHandleMousedown(e) { onBottomHandleMousedown(evt) {
const main = this.$el as any; const main = this.$el as any;
const base = e.clientY; const base = evt.clientY;
const height = parseInt(getComputedStyle(main, '').height, 10); const height = parseInt(getComputedStyle(main, '').height, 10);
const top = parseInt(getComputedStyle(main, '').top, 10); const top = parseInt(getComputedStyle(main, '').top, 10);
const browserHeight = window.innerHeight; const browserHeight = window.innerHeight;
@ -278,10 +278,10 @@ export default defineComponent({
}, },
// //
onLeftHandleMousedown(e) { onLeftHandleMousedown(evt) {
const main = this.$el as any; const main = this.$el as any;
const base = e.clientX; const base = evt.clientX;
const width = parseInt(getComputedStyle(main, '').width, 10); const width = parseInt(getComputedStyle(main, '').width, 10);
const left = parseInt(getComputedStyle(main, '').left, 10); const left = parseInt(getComputedStyle(main, '').left, 10);
@ -304,27 +304,27 @@ export default defineComponent({
}, },
// //
onTopLeftHandleMousedown(e) { onTopLeftHandleMousedown(evt) {
this.onTopHandleMousedown(e); this.onTopHandleMousedown(evt);
this.onLeftHandleMousedown(e); this.onLeftHandleMousedown(evt);
}, },
// //
onTopRightHandleMousedown(e) { onTopRightHandleMousedown(evt) {
this.onTopHandleMousedown(e); this.onTopHandleMousedown(evt);
this.onRightHandleMousedown(e); this.onRightHandleMousedown(evt);
}, },
// //
onBottomRightHandleMousedown(e) { onBottomRightHandleMousedown(evt) {
this.onBottomHandleMousedown(e); this.onBottomHandleMousedown(evt);
this.onRightHandleMousedown(e); this.onRightHandleMousedown(evt);
}, },
// //
onBottomLeftHandleMousedown(e) { onBottomLeftHandleMousedown(evt) {
this.onBottomHandleMousedown(e); this.onBottomHandleMousedown(evt);
this.onLeftHandleMousedown(e); this.onLeftHandleMousedown(evt);
}, },
// //

View file

@ -70,7 +70,7 @@ export default defineComponent({
}, },
mounted() { mounted() {
if (typeof this.q == 'object') { if (typeof this.q === 'object') {
this.user = this.q; this.user = this.q;
this.fetched = true; this.fetched = true;
} else { } else {

View file

@ -60,9 +60,9 @@ import * as os from '@/os';
import { defaultStore } from '@/store'; import { defaultStore } from '@/store';
const emit = defineEmits<{ const emit = defineEmits<{
(e: 'ok', selected: misskey.entities.UserDetailed): void; (ev: 'ok', selected: misskey.entities.UserDetailed): void;
(e: 'cancel'): void; (ev: 'cancel'): void;
(e: 'closed'): void; (ev: 'closed'): void;
}>(); }>();
let username = $ref(''); let username = $ref('');

View file

@ -57,9 +57,9 @@ const props = withDefaults(defineProps<{
}); });
const emit = defineEmits<{ const emit = defineEmits<{
(e: 'changeVisibility', v: typeof misskey.noteVisibilities[number]): void; (ev: 'changeVisibility', v: typeof misskey.noteVisibilities[number]): void;
(e: 'changeLocalOnly', v: boolean): void; (ev: 'changeLocalOnly', v: boolean): void;
(e: 'closed'): void; (ev: 'closed'): void;
}>(); }>();
let v = $ref(props.currentVisibility); let v = $ref(props.currentVisibility);

View file

@ -21,8 +21,8 @@ const props = defineProps<{
}>(); }>();
const emit = defineEmits<{ const emit = defineEmits<{
(e: 'done'); (ev: 'done');
(e: 'closed'); (ev: 'closed');
}>(); }>();
function done() { function done() {

View file

@ -19,7 +19,7 @@
<div class="customize-container"> <div class="customize-container">
<button class="config _button" @click.prevent.stop="configWidget(element.id)"><i class="fas fa-cog"></i></button> <button class="config _button" @click.prevent.stop="configWidget(element.id)"><i class="fas fa-cog"></i></button>
<button class="remove _button" @click.prevent.stop="removeWidget(element)"><i class="fas fa-times"></i></button> <button class="remove _button" @click.prevent.stop="removeWidget(element)"><i class="fas fa-times"></i></button>
<component class="handle" :ref="el => widgetRefs[element.id] = el" :is="`mkw-${element.name}`" :widget="element" @updateProps="updateWidget(element.id, $event)"/> <component :is="`mkw-${element.name}`" :ref="el => widgetRefs[element.id] = el" class="handle" :widget="element" @updateProps="updateWidget(element.id, $event)"/>
</div> </div>
</template> </template>
</XDraggable> </XDraggable>

View file

@ -1,7 +1,7 @@
export default (v, digits = 0) => { export default (v, digits = 0) => {
if (v == null) return '?'; if (v == null) return '?';
const sizes = ['B', 'KB', 'MB', 'GB', 'TB']; const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
if (v == 0) return '0'; if (v === 0) return '0';
const isMinus = v < 0; const isMinus = v < 0;
if (isMinus) v = -v; if (isMinus) v = -v;
const i = Math.floor(Math.log(v) / Math.log(1024)); const i = Math.floor(Math.log(v) / Math.log(1024));

View file

@ -146,7 +146,7 @@ if ($i && $i.token) {
try { try {
document.body.innerHTML = '<div>Please wait...</div>'; document.body.innerHTML = '<div>Please wait...</div>';
await login(i); await login(i);
} catch (e) { } catch (err) {
// Render the error screen // Render the error screen
// TODO: ちゃんとしたコンポーネントをレンダリングする(v10とかのトラブルシューティングゲーム付きのやつみたいな) // TODO: ちゃんとしたコンポーネントをレンダリングする(v10とかのトラブルシューティングゲーム付きのやつみたいな)
document.body.innerHTML = '<div id="err">Oops!</div>'; document.body.innerHTML = '<div id="err">Oops!</div>';
@ -249,7 +249,7 @@ if (lastVersion !== version) {
popup(defineAsyncComponent(() => import('@/components/updated.vue')), {}, {}, 'closed'); popup(defineAsyncComponent(() => import('@/components/updated.vue')), {}, {}, 'closed');
} }
} }
} catch (e) { } catch (err) {
} }
} }
@ -334,7 +334,7 @@ stream.on('_disconnected_', async () => {
} }
}); });
stream.on('emojiAdded', data => { stream.on('emojiAdded', emojiData => {
// TODO // TODO
//store.commit('instance/set', ); //store.commit('instance/set', );
}); });

View file

@ -4,11 +4,11 @@ import { api } from './os';
// TODO: 他のタブと永続化されたstateを同期 // TODO: 他のタブと永続化されたstateを同期
const data = localStorage.getItem('instance'); const instanceData = localStorage.getItem('instance');
// TODO: instanceをリアクティブにするかは再考の余地あり // TODO: instanceをリアクティブにするかは再考の余地あり
export const instance: Misskey.entities.InstanceMetadata = reactive(data ? JSON.parse(data) : { export const instance: Misskey.entities.InstanceMetadata = reactive(instanceData ? JSON.parse(instanceData) : {
// TODO: set default values // TODO: set default values
}); });

View file

@ -59,10 +59,10 @@ export const apiWithDialog = ((
token?: string | null | undefined, token?: string | null | undefined,
) => { ) => {
const promise = api(endpoint, data, token); const promise = api(endpoint, data, token);
promiseDialog(promise, null, (e) => { promiseDialog(promise, null, (err) => {
alert({ alert({
type: 'error', type: 'error',
text: e.message + '\n' + (e as any).id, text: err.message + '\n' + (err as any).id,
}); });
}); });
@ -72,7 +72,7 @@ export const apiWithDialog = ((
export function promiseDialog<T extends Promise<any>>( export function promiseDialog<T extends Promise<any>>(
promise: T, promise: T,
onSuccess?: ((res: any) => void) | null, onSuccess?: ((res: any) => void) | null,
onFailure?: ((e: Error) => void) | null, onFailure?: ((err: Error) => void) | null,
text?: string, text?: string,
): T { ): T {
const showing = ref(true); const showing = ref(true);
@ -88,14 +88,14 @@ export function promiseDialog<T extends Promise<any>>(
showing.value = false; showing.value = false;
}, 1000); }, 1000);
} }
}).catch(e => { }).catch(err => {
showing.value = false; showing.value = false;
if (onFailure) { if (onFailure) {
onFailure(e); onFailure(err);
} else { } else {
alert({ alert({
type: 'error', type: 'error',
text: e text: err,
}); });
} }
}); });

View file

@ -175,10 +175,10 @@ const menu = (ev: MouseEvent) => {
type: 'info', type: 'info',
text: i18n.ts.exportRequested, text: i18n.ts.exportRequested,
}); });
}).catch((e) => { }).catch((err) => {
os.alert({ os.alert({
type: 'error', type: 'error',
text: e.message, text: err.message,
}); });
}); });
} }
@ -195,10 +195,10 @@ const menu = (ev: MouseEvent) => {
type: 'info', type: 'info',
text: i18n.ts.importRequested, text: i18n.ts.importRequested,
}); });
}).catch((e) => { }).catch((err) => {
os.alert({ os.alert({
type: 'error', type: 'error',
text: e.message, text: err.message,
}); });
}); });
} }

View file

@ -265,10 +265,10 @@ const invite = () => {
type: 'info', type: 'info',
text: x.code text: x.code
}); });
}).catch(e => { }).catch(err => {
os.alert({ os.alert({
type: 'error', type: 'error',
text: e text: err,
}); });
}); });
}; };

View file

@ -111,8 +111,8 @@ export default defineComponent({
} }
}, },
setBannerImage(e) { setBannerImage(evt) {
selectFile(e.currentTarget ?? e.target, null).then(file => { selectFile(evt.currentTarget ?? evt.target, null).then(file => {
this.bannerId = file.id; this.bannerId = file.id;
}); });
}, },

View file

@ -79,9 +79,9 @@ export default defineComponent({
} }
if (this.selectedTags.size === 0) { if (this.selectedTags.size === 0) {
this.searchEmojis = this.customEmojis.filter(e => e.name.includes(this.q) || e.aliases.includes(this.q)); this.searchEmojis = this.customEmojis.filter(emoji => emoji.name.includes(this.q) || emoji.aliases.includes(this.q));
} else { } else {
this.searchEmojis = this.customEmojis.filter(e => (e.name.includes(this.q) || e.aliases.includes(this.q)) && [...this.selectedTags].every(t => e.aliases.includes(t))); this.searchEmojis = this.customEmojis.filter(emoji => (emoji.name.includes(this.q) || emoji.aliases.includes(this.q)) && [...this.selectedTags].every(t => emoji.aliases.includes(t)));
} }
}, },

View file

@ -25,10 +25,10 @@ function menu(ev) {
type: 'info', type: 'info',
text: i18n.ts.exportRequested, text: i18n.ts.exportRequested,
}); });
}).catch((e) => { }).catch((err) => {
os.alert({ os.alert({
type: 'error', type: 'error',
text: e.message, text: err.message,
}); });
}); });
} }

View file

@ -20,7 +20,7 @@ export default defineComponent({
uri: acct uri: acct
}); });
promise.then(res => { promise.then(res => {
if (res.type == 'User') { if (res.type === 'User') {
this.follow(res.object); this.follow(res.object);
} else if (res.type === 'Note') { } else if (res.type === 'Note') {
this.$router.push(`/notes/${res.object.id}`); this.$router.push(`/notes/${res.object.id}`);

View file

@ -91,8 +91,8 @@ export default defineComponent({
}, },
methods: { methods: {
selectFile(e) { selectFile(evt) {
selectFiles(e.currentTarget ?? e.target, null).then(files => { selectFiles(evt.currentTarget ?? evt.target, null).then(files => {
this.files = this.files.concat(files); this.files = this.files.concat(files);
}); });
}, },

View file

@ -119,8 +119,8 @@ export default defineComponent({
postId: this.postId postId: this.postId
}).then(post => { }).then(post => {
this.post = post; this.post = post;
}).catch(e => { }).catch(err => {
this.error = e; this.error = err;
}); });
}, },

View file

@ -90,14 +90,14 @@ export default defineComponent({
getAcct: Acct.toString, getAcct: Acct.toString,
isMe(message) { isMe(message) {
return message.userId == this.$i.id; return message.userId === this.$i.id;
}, },
onMessage(message) { onMessage(message) {
if (message.recipientId) { if (message.recipientId) {
this.messages = this.messages.filter(m => !( this.messages = this.messages.filter(m => !(
(m.recipientId == message.recipientId && m.userId == message.userId) || (m.recipientId === message.recipientId && m.userId === message.userId) ||
(m.recipientId == message.userId && m.userId == message.recipientId))); (m.recipientId === message.userId && m.userId === message.recipientId)));
this.messages.unshift(message); this.messages.unshift(message);
} else if (message.groupId) { } else if (message.groupId) {
@ -108,7 +108,7 @@ export default defineComponent({
onRead(ids) { onRead(ids) {
for (const id of ids) { for (const id of ids) {
const found = this.messages.find(m => m.id == id); const found = this.messages.find(m => m.id === id);
if (found) { if (found) {
if (found.recipientId) { if (found.recipientId) {
found.isRead = true; found.isRead = true;

View file

@ -59,7 +59,7 @@ export default defineComponent({
return this.user ? 'user:' + this.user.id : 'group:' + this.group.id; return this.user ? 'user:' + this.user.id : 'group:' + this.group.id;
}, },
canSend(): boolean { canSend(): boolean {
return (this.text != null && this.text != '') || this.file != null; return (this.text != null && this.text !== '') || this.file != null;
}, },
room(): any { room(): any {
return this.$parent; return this.$parent;
@ -88,12 +88,11 @@ export default defineComponent({
} }
}, },
methods: { methods: {
async onPaste(e: ClipboardEvent) { async onPaste(evt: ClipboardEvent) {
const data = e.clipboardData; const items = evt.clipboardData.items;
const items = data.items;
if (items.length == 1) { if (items.length === 1) {
if (items[0].kind == 'file') { if (items[0].kind === 'file') {
const file = items[0].getAsFile(); const file = items[0].getAsFile();
const lio = file.name.lastIndexOf('.'); const lio = file.name.lastIndexOf('.');
const ext = lio >= 0 ? file.name.slice(lio) : ''; const ext = lio >= 0 ? file.name.slice(lio) : '';
@ -101,7 +100,7 @@ export default defineComponent({
if (formatted) this.upload(file, formatted); if (formatted) this.upload(file, formatted);
} }
} else { } else {
if (items[0].kind == 'file') { if (items[0].kind === 'file') {
os.alert({ os.alert({
type: 'error', type: 'error',
text: this.$ts.onlyOneFileCanBeAttached text: this.$ts.onlyOneFileCanBeAttached
@ -110,23 +109,23 @@ export default defineComponent({
} }
}, },
onDragover(e) { onDragover(evt) {
const isFile = e.dataTransfer.items[0].kind == 'file'; const isFile = evt.dataTransfer.items[0].kind === 'file';
const isDriveFile = e.dataTransfer.types[0] == _DATA_TRANSFER_DRIVE_FILE_; const isDriveFile = evt.dataTransfer.types[0] === _DATA_TRANSFER_DRIVE_FILE_;
if (isFile || isDriveFile) { if (isFile || isDriveFile) {
e.preventDefault(); evt.preventDefault();
e.dataTransfer.dropEffect = e.dataTransfer.effectAllowed == 'all' ? 'copy' : 'move'; evt.dataTransfer.dropEffect = evt.dataTransfer.effectAllowed === 'all' ? 'copy' : 'move';
} }
}, },
onDrop(e): void { onDrop(evt): void {
// //
if (e.dataTransfer.files.length == 1) { if (evt.dataTransfer.files.length === 1) {
e.preventDefault(); evt.preventDefault();
this.upload(e.dataTransfer.files[0]); this.upload(evt.dataTransfer.files[0]);
return; return;
} else if (e.dataTransfer.files.length > 1) { } else if (evt.dataTransfer.files.length > 1) {
e.preventDefault(); evt.preventDefault();
os.alert({ os.alert({
type: 'error', type: 'error',
text: this.$ts.onlyOneFileCanBeAttached text: this.$ts.onlyOneFileCanBeAttached
@ -135,17 +134,17 @@ export default defineComponent({
} }
//#region //#region
const driveFile = e.dataTransfer.getData(_DATA_TRANSFER_DRIVE_FILE_); const driveFile = evt.dataTransfer.getData(_DATA_TRANSFER_DRIVE_FILE_);
if (driveFile != null && driveFile != '') { if (driveFile != null && driveFile !== '') {
this.file = JSON.parse(driveFile); this.file = JSON.parse(driveFile);
e.preventDefault(); evt.preventDefault();
} }
//#endregion //#endregion
}, },
onKeydown(e) { onKeydown(evt) {
this.typing(); this.typing();
if ((e.which == 10 || e.which == 13) && (e.ctrlKey || e.metaKey) && this.canSend) { if ((evt.which === 10 || evt.which === 13) && (evt.ctrlKey || evt.metaKey) && this.canSend) {
this.send(); this.send();
} }
}, },
@ -154,8 +153,8 @@ export default defineComponent({
this.typing(); this.typing();
}, },
chooseFile(e) { chooseFile(evt) {
selectFile(e.currentTarget ?? e.target, this.$ts.selectFile).then(file => { selectFile(evt.currentTarget ?? evt.target, this.$ts.selectFile).then(file => {
this.file = file; this.file = file;
}); });
}, },
@ -193,9 +192,9 @@ export default defineComponent({
}, },
saveDraft() { saveDraft() {
const data = JSON.parse(localStorage.getItem('message_drafts') || '{}'); const drafts = JSON.parse(localStorage.getItem('message_drafts') || '{}');
data[this.draftKey] = { drafts[this.draftKey] = {
updatedAt: new Date(), updatedAt: new Date(),
data: { data: {
text: this.text, text: this.text,
@ -203,15 +202,15 @@ export default defineComponent({
} }
} }
localStorage.setItem('message_drafts', JSON.stringify(data)); localStorage.setItem('message_drafts', JSON.stringify(drafts));
}, },
deleteDraft() { deleteDraft() {
const data = JSON.parse(localStorage.getItem('message_drafts') || '{}'); const drafts = JSON.parse(localStorage.getItem('message_drafts') || '{}');
delete data[this.draftKey]; delete drafts[this.draftKey];
localStorage.setItem('message_drafts', JSON.stringify(data)); localStorage.setItem('message_drafts', JSON.stringify(drafts));
}, },
async insertEmoji(ev) { async insertEmoji(ev) {

View file

@ -166,23 +166,23 @@ const Component = defineComponent({
}); });
}, },
onDragover(e) { onDragover(evt) {
const isFile = e.dataTransfer.items[0].kind == 'file'; const isFile = evt.dataTransfer.items[0].kind === 'file';
const isDriveFile = e.dataTransfer.types[0] == _DATA_TRANSFER_DRIVE_FILE_; const isDriveFile = evt.dataTransfer.types[0] === _DATA_TRANSFER_DRIVE_FILE_;
if (isFile || isDriveFile) { if (isFile || isDriveFile) {
e.dataTransfer.dropEffect = e.dataTransfer.effectAllowed == 'all' ? 'copy' : 'move'; evt.dataTransfer.dropEffect = evt.dataTransfer.effectAllowed === 'all' ? 'copy' : 'move';
} else { } else {
e.dataTransfer.dropEffect = 'none'; evt.dataTransfer.dropEffect = 'none';
} }
}, },
onDrop(e): void { onDrop(evt): void {
// //
if (e.dataTransfer.files.length == 1) { if (evt.dataTransfer.files.length === 1) {
this.form.upload(e.dataTransfer.files[0]); this.form.upload(evt.dataTransfer.files[0]);
return; return;
} else if (e.dataTransfer.files.length > 1) { } else if (evt.dataTransfer.files.length > 1) {
os.alert({ os.alert({
type: 'error', type: 'error',
text: this.$ts.onlyOneFileCanBeAttached text: this.$ts.onlyOneFileCanBeAttached
@ -191,8 +191,8 @@ const Component = defineComponent({
} }
//#region //#region
const driveFile = e.dataTransfer.getData(_DATA_TRANSFER_DRIVE_FILE_); const driveFile = evt.dataTransfer.getData(_DATA_TRANSFER_DRIVE_FILE_);
if (driveFile != null && driveFile != '') { if (driveFile != null && driveFile !== '') {
const file = JSON.parse(driveFile); const file = JSON.parse(driveFile);
this.form.file = file; this.form.file = file;
} }
@ -209,7 +209,7 @@ const Component = defineComponent({
limit: max + 1, limit: max + 1,
untilId: this.existMoreMessages ? this.messages[0].id : undefined untilId: this.existMoreMessages ? this.messages[0].id : undefined
}).then(messages => { }).then(messages => {
if (messages.length == max + 1) { if (messages.length === max + 1) {
this.existMoreMessages = true; this.existMoreMessages = true;
messages.pop(); messages.pop();
} else { } else {
@ -235,7 +235,7 @@ const Component = defineComponent({
const _isBottom = isBottom(this.$el, 64); const _isBottom = isBottom(this.$el, 64);
this.messages.push(message); this.messages.push(message);
if (message.userId != this.$i.id && !document.hidden) { if (message.userId !== this.$i.id && !document.hidden) {
this.connection.send('read', { this.connection.send('read', {
id: message.id id: message.id
}); });
@ -246,7 +246,7 @@ const Component = defineComponent({
this.$nextTick(() => { this.$nextTick(() => {
this.scrollToBottom(); this.scrollToBottom();
}); });
} else if (message.userId != this.$i.id) { } else if (message.userId !== this.$i.id) {
// Notify // Notify
this.notifyNewMessage(); this.notifyNewMessage();
} }
@ -256,7 +256,7 @@ const Component = defineComponent({
if (this.user) { if (this.user) {
if (!Array.isArray(x)) x = [x]; if (!Array.isArray(x)) x = [x];
for (const id of x) { for (const id of x) {
if (this.messages.some(x => x.id == id)) { if (this.messages.some(x => x.id === id)) {
const exist = this.messages.map(x => x.id).indexOf(id); const exist = this.messages.map(x => x.id).indexOf(id);
this.messages[exist] = { this.messages[exist] = {
...this.messages[exist], ...this.messages[exist],
@ -266,7 +266,7 @@ const Component = defineComponent({
} }
} else if (this.group) { } else if (this.group) {
for (const id of x.ids) { for (const id of x.ids) {
if (this.messages.some(x => x.id == id)) { if (this.messages.some(x => x.id === id)) {
const exist = this.messages.map(x => x.id).indexOf(id); const exist = this.messages.map(x => x.id).indexOf(id);
this.messages[exist] = { this.messages[exist] = {
...this.messages[exist], ...this.messages[exist],

View file

@ -136,8 +136,8 @@ export default defineComponent({
this.hasPrev = prev.length !== 0; this.hasPrev = prev.length !== 0;
this.hasNext = next.length !== 0; this.hasNext = next.length !== 0;
}); });
}).catch(e => { }).catch(err => {
this.error = e; this.error = err;
}); });
} }
} }

View file

@ -139,8 +139,8 @@ export default defineComponent({
username: this.username, username: this.username,
}).then(page => { }).then(page => {
this.page = page; this.page = page;
}).catch(e => { }).catch(err => {
this.error = e; this.error = err;
}); });
}, },

View file

@ -121,10 +121,10 @@ function submit() {
}).then(() => { }).then(() => {
os.success(); os.success();
$i!.twoFactorEnabled = true; $i!.twoFactorEnabled = true;
}).catch(e => { }).catch(err => {
os.alert({ os.alert({
type: 'error', type: 'error',
text: e text: err,
}); });
}); });
} }

View file

@ -43,7 +43,7 @@ async function install() {
let ast; let ast;
try { try {
ast = parse(code.value); ast = parse(code.value);
} catch (e) { } catch (err) {
os.alert({ os.alert({
type: 'error', type: 'error',
text: 'Syntax error :(' text: 'Syntax error :('
@ -60,8 +60,8 @@ async function install() {
return; return;
} }
const data = meta.get(null); const metadata = meta.get(null);
if (data == null) { if (metadata == null) {
os.alert({ os.alert({
type: 'error', type: 'error',
text: 'No metadata found :(' text: 'No metadata found :('
@ -69,7 +69,7 @@ async function install() {
return; return;
} }
const { name, version, author, description, permissions, config } = data; const { name, version, author, description, permissions, config } = metadata;
if (name == null || version == null || author == null) { if (name == null || version == null || author == null) {
os.alert({ os.alert({
type: 'error', type: 'error',

View file

@ -29,7 +29,7 @@ function parseThemeCode(code: string) {
try { try {
theme = JSON5.parse(code); theme = JSON5.parse(code);
} catch (e) { } catch (err) {
os.alert({ os.alert({
type: 'error', type: 'error',
text: i18n.ts._theme.invalid text: i18n.ts._theme.invalid

View file

@ -43,6 +43,14 @@ import * as os from '@/os';
import * as symbols from '@/symbols'; import * as symbols from '@/symbols';
import { i18n } from '@/i18n'; import { i18n } from '@/i18n';
defineExpose({
[symbols.PAGE_INFO]: {
title: 'Edit webhook',
icon: 'fas fa-bolt',
bg: 'var(--bg)',
},
});
const webhook = await os.api('i/webhooks/show', { const webhook = await os.api('i/webhooks/show', {
webhookId: new URLSearchParams(window.location.search).get('id') webhookId: new URLSearchParams(window.location.search).get('id')
}); });
@ -78,12 +86,4 @@ async function save(): Promise<void> {
active, active,
}); });
} }
defineExpose({
[symbols.PAGE_INFO]: {
title: 'Edit webhook',
icon: 'fas fa-bolt',
bg: 'var(--bg)',
},
});
</script> </script>

View file

@ -71,7 +71,7 @@ watch(hardMutedWords, () => {
async function save() { async function save() {
const parseMutes = (mutes, tab) => { const parseMutes = (mutes, tab) => {
// split into lines, remove empty lines and unnecessary whitespace // split into lines, remove empty lines and unnecessary whitespace
let lines = mutes.trim().split('\n').map(line => line.trim()).filter(line => line != ''); let lines = mutes.trim().split('\n').map(line => line.trim()).filter(line => line !== '');
// check each line if it is a RegExp or not // check each line if it is a RegExp or not
for (let i = 0; i < lines.length; i++) { for (let i = 0; i < lines.length; i++) {

View file

@ -153,11 +153,11 @@ export default defineComponent({
); );
} }
//#endregion //#endregion
} catch (e) { } catch (err) {
os.alert({ os.alert({
type: 'error', type: 'error',
title: e.message, title: err.message,
text: e.name text: err.name
}); });
} }

View file

@ -128,7 +128,7 @@ function showPreview() {
} }
function setBgColor(color: typeof bgColors[number]) { function setBgColor(color: typeof bgColors[number]) {
if (theme.base != color.kind) { if (theme.base !== color.kind) {
const base = color.kind === 'dark' ? darkTheme : lightTheme; const base = color.kind === 'dark' ? darkTheme : lightTheme;
for (const prop of Object.keys(base.props)) { for (const prop of Object.keys(base.props)) {
if (prop === 'accent') continue; if (prop === 'accent') continue;

View file

@ -232,10 +232,10 @@ export default defineComponent({
await os.api('admin/delete-all-files-of-a-user', { userId: this.user.id }); await os.api('admin/delete-all-files-of-a-user', { userId: this.user.id });
os.success(); os.success();
}; };
await process().catch(e => { await process().catch(err => {
os.alert({ os.alert({
type: 'error', type: 'error',
text: e.toString() text: err.toString(),
}); });
}); });
await this.refreshUser(); await this.refreshUser();

View file

@ -260,8 +260,8 @@ export default defineComponent({
this.user = null; this.user = null;
os.api('users/show', Acct.parse(this.acct)).then(user => { os.api('users/show', Acct.parse(this.acct)).then(user => {
this.user = user; this.user = user;
}).catch(e => { }).catch(err => {
this.error = e; this.error = err;
}); });
}, },

View file

@ -14,9 +14,9 @@ export async function fetchThemes(): Promise<void> {
try { try {
const themes = await api('i/registry/get', { scope: ['client'], key: 'themes' }); const themes = await api('i/registry/get', { scope: ['client'], key: 'themes' });
localStorage.setItem(lsCacheKey, JSON.stringify(themes)); localStorage.setItem(lsCacheKey, JSON.stringify(themes));
} catch (e) { } catch (err) {
if (e.code === 'NO_SUCH_KEY') return; if (err.code === 'NO_SUCH_KEY') return;
throw e; throw err;
} }
} }
@ -28,7 +28,7 @@ export async function addTheme(theme: Theme): Promise<void> {
} }
export async function removeTheme(theme: Theme): Promise<void> { export async function removeTheme(theme: Theme): Promise<void> {
const themes = getThemes().filter(t => t.id != theme.id); const themes = getThemes().filter(t => t.id !== theme.id);
await api('i/registry/set', { scope: ['client'], key: 'themes', value: themes }); await api('i/registry/set', { scope: ['client'], key: 'themes', value: themes });
localStorage.setItem(lsCacheKey, JSON.stringify(themes)); localStorage.setItem(lsCacheKey, JSON.stringify(themes));
} }

View file

@ -14,30 +14,29 @@ export function swInject() {
console.log('sw msg', ev.data); console.log('sw msg', ev.data);
} }
const data = ev.data; // as SwMessage if (ev.data.type !== 'order') return;
if (data.type !== 'order') return;
if (data.loginId !== $i?.id) { if (ev.data.loginId !== $i?.id) {
return getAccountFromId(data.loginId).then(account => { return getAccountFromId(ev.data.loginId).then(account => {
if (!account) return; if (!account) return;
return login(account.token, data.url); return login(account.token, ev.data.url);
}); });
} }
switch (data.order) { switch (ev.data.order) {
case 'post': case 'post':
return post(data.options); return post(ev.data.options);
case 'push': case 'push':
if (router.currentRoute.value.path === data.url) { if (router.currentRoute.value.path === ev.data.url) {
return window.scroll({ top: 0, behavior: 'smooth' }); return window.scroll({ top: 0, behavior: 'smooth' });
} }
if (navHook) { if (navHook) {
return navHook(data.url); return navHook(ev.data.url);
} }
if (sideViewHook && defaultStore.state.defaultSideView && data.url !== '/') { if (sideViewHook && defaultStore.state.defaultSideView && ev.data.url !== '/') {
return sideViewHook(data.url); return sideViewHook(ev.data.url);
} }
return router.push(data.url); return router.push(ev.data.url);
default: default:
return; return;
} }

View file

@ -44,13 +44,13 @@ export default defineComponent({
}, },
removeWidget(widget) { removeWidget(widget) {
this.$store.set('widgets', this.$store.state.widgets.filter(w => w.id != widget.id)); this.$store.set('widgets', this.$store.state.widgets.filter(w => w.id !== widget.id));
}, },
updateWidget({ id, data }) { updateWidget({ id, data }) {
this.$store.set('widgets', this.$store.state.widgets.map(w => w.id === id ? { this.$store.set('widgets', this.$store.state.widgets.map(w => w.id === id ? {
...w, ...w,
data: data data,
} : w)); } : w));
}, },

View file

@ -276,14 +276,14 @@ export function setColumnWidgets(id: Column['id'], widgets: ColumnWidget[]) {
saveDeck(); saveDeck();
} }
export function updateColumnWidget(id: Column['id'], widgetId: string, data: any) { export function updateColumnWidget(id: Column['id'], widgetId: string, WidgetData: any) {
const columns = copy(deckStore.state.columns); const columns = copy(deckStore.state.columns);
const columnIndex = deckStore.state.columns.findIndex(c => c.id === id); const columnIndex = deckStore.state.columns.findIndex(c => c.id === id);
const column = copy(deckStore.state.columns[columnIndex]); const column = copy(deckStore.state.columns[columnIndex]);
if (column == null) return; if (column == null) return;
column.widgets = column.widgets.map(w => w.id === widgetId ? { column.widgets = column.widgets.map(w => w.id === widgetId ? {
...w, ...w,
data: data data: widgetData,
} : w); } : w);
columns[columnIndex] = column; columns[columnIndex] = column;
deckStore.set('columns', columns); deckStore.set('columns', columns);

View file

@ -14,7 +14,7 @@ import { i18n } from '@/i18n';
import { defaultStore } from '@/store'; import { defaultStore } from '@/store';
const emit = defineEmits<{ const emit = defineEmits<{
(e: 'mounted', el: Element): void; (ev: 'mounted', el: Element): void;
}>(); }>();
let editMode = $ref(false); let editMode = $ref(false);
@ -32,13 +32,13 @@ function addWidget(widget) {
} }
function removeWidget(widget) { function removeWidget(widget) {
defaultStore.set('widgets', defaultStore.state.widgets.filter(w => w.id != widget.id)); defaultStore.set('widgets', defaultStore.state.widgets.filter(w => w.id !== widget.id));
} }
function updateWidget({ id, data }) { function updateWidget({ id, data }) {
defaultStore.set('widgets', defaultStore.state.widgets.map(w => w.id === id ? { defaultStore.set('widgets', defaultStore.state.widgets.map(w => w.id === id ? {
...w, ...w,
data: data data,
} : w)); } : w));
} }