From b462e9d1fcdbc7e8b207896a50288e809f14746c Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Thu, 27 Jul 2023 00:44:38 +0200 Subject: [PATCH] chore: code reformat --- .../backend/src/models/repositories/note.ts | 3 +- .../mastodon/ApiMastodonCompatibleService.ts | 27 ++-- .../src/server/api/mastodon/endpoints/meta.ts | 16 +- .../src/components/MkDateSeparatedList.vue | 2 +- .../client/src/components/MkPageWindow.vue | 20 +-- packages/client/src/pages/about-firefish.vue | 4 +- .../client/src/pages/settings/general.vue | 3 +- packages/client/src/pages/settings/navbar.vue | 144 ++++++++++++------ 8 files changed, 141 insertions(+), 78 deletions(-) diff --git a/packages/backend/src/models/repositories/note.ts b/packages/backend/src/models/repositories/note.ts index ecd5ead6d..25b8e8083 100644 --- a/packages/backend/src/models/repositories/note.ts +++ b/packages/backend/src/models/repositories/note.ts @@ -295,8 +295,7 @@ export const NoteRepository = db.getRepository(Note).extend({ ): Promise | undefined> { try { return await this.pack(src, me, options); - } - catch { + } catch { return undefined; } }, diff --git a/packages/backend/src/server/api/mastodon/ApiMastodonCompatibleService.ts b/packages/backend/src/server/api/mastodon/ApiMastodonCompatibleService.ts index bd868c64b..44485ac42 100644 --- a/packages/backend/src/server/api/mastodon/ApiMastodonCompatibleService.ts +++ b/packages/backend/src/server/api/mastodon/ApiMastodonCompatibleService.ts @@ -8,7 +8,11 @@ import { apiTimelineMastodon } from "./endpoints/timeline.js"; import { apiNotificationsMastodon } from "./endpoints/notifications.js"; import { apiSearchMastodon } from "./endpoints/search.js"; import { getInstance } from "./endpoints/meta.js"; -import {convertAccount, convertAnnouncement, convertFilter} from "./converters.js"; +import { + convertAccount, + convertAnnouncement, + convertFilter, +} from "./converters.js"; import { convertId, IdType } from "../index.js"; import { Users } from "@/models/index.js"; import { IsNull } from "typeorm"; @@ -55,15 +59,18 @@ export function apiMastodonCompatible(router: Router): void { try { const data = await client.getInstance(); const admin = await Users.findOne({ - where: { - host: IsNull(), - isAdmin: true, - isDeleted: false, - isSuspended: false, - }, - order: { id: "ASC" }, - }); - const contact = admin == null ? null : convertAccount((await client.getAccount(admin.id)).data); + where: { + host: IsNull(), + isAdmin: true, + isDeleted: false, + isSuspended: false, + }, + order: { id: "ASC" }, + }); + const contact = + admin == null + ? null + : convertAccount((await client.getAccount(admin.id)).data); ctx.body = await getInstance(data.data, contact); } catch (e: any) { console.error(e); diff --git a/packages/backend/src/server/api/mastodon/endpoints/meta.ts b/packages/backend/src/server/api/mastodon/endpoints/meta.ts index 100ff4be4..c8556aa6b 100644 --- a/packages/backend/src/server/api/mastodon/endpoints/meta.ts +++ b/packages/backend/src/server/api/mastodon/endpoints/meta.ts @@ -6,13 +6,15 @@ import { IsNull } from "typeorm"; import { MAX_NOTE_TEXT_LENGTH, FILE_TYPE_BROWSERSAFE } from "@/const.js"; // TODO: add iceshrimp features -export async function getInstance(response: Entity.Instance, contact: Entity.Account) { - const [meta, totalUsers, totalStatuses] = - await Promise.all([ - fetchMeta(true), - Users.count({ where: { host: IsNull() } }), - Notes.count({ where: { userHost: IsNull() } }), - ]); +export async function getInstance( + response: Entity.Instance, + contact: Entity.Account, +) { + const [meta, totalUsers, totalStatuses] = await Promise.all([ + fetchMeta(true), + Users.count({ where: { host: IsNull() } }), + Notes.count({ where: { userHost: IsNull() } }), + ]); return { uri: response.uri, diff --git a/packages/client/src/components/MkDateSeparatedList.vue b/packages/client/src/components/MkDateSeparatedList.vue index d84b5ba58..19461a93d 100644 --- a/packages/client/src/components/MkDateSeparatedList.vue +++ b/packages/client/src/components/MkDateSeparatedList.vue @@ -26,7 +26,7 @@ export default defineComponent({ type: Boolean, required: false, default: false, - } + }, }, setup(props, { slots, expose }) { diff --git a/packages/client/src/components/MkPageWindow.vue b/packages/client/src/components/MkPageWindow.vue index b6a1999fe..88da05ffa 100644 --- a/packages/client/src/components/MkPageWindow.vue +++ b/packages/client/src/components/MkPageWindow.vue @@ -78,16 +78,16 @@ const buttonsLeft = $computed(() => { }); const buttonsRight = $computed(() => { const buttons = [ - { - icon: 'ph-arrow-clockwise ph-bold ph-lg', - title: i18n.ts.reload, - onClick: reload, - }, - { - icon: "ph-arrows-out-simple ph-bold ph-lg", - title: i18n.ts.showInPage, - onClick: expand, - }, + { + icon: "ph-arrow-clockwise ph-bold ph-lg", + title: i18n.ts.reload, + onClick: reload, + }, + { + icon: "ph-arrows-out-simple ph-bold ph-lg", + title: i18n.ts.showInPage, + onClick: expand, + }, ]; return buttons; diff --git a/packages/client/src/pages/about-firefish.vue b/packages/client/src/pages/about-firefish.vue index c02da0dad..b41f47825 100644 --- a/packages/client/src/pages/about-firefish.vue +++ b/packages/client/src/pages/about-firefish.vue @@ -64,7 +64,9 @@ > {{ i18n.ts._aboutIceshrimp.source }} - + diff --git a/packages/client/src/pages/settings/general.vue b/packages/client/src/pages/settings/general.vue index 4a8c8d198..6865b7cdc 100644 --- a/packages/client/src/pages/settings/general.vue +++ b/packages/client/src/pages/settings/general.vue @@ -8,7 +8,8 @@