From e35f3eef56f4779ba56170652472f835aedc5fd2 Mon Sep 17 00:00:00 2001 From: Kio-td Date: Sat, 11 Feb 2023 06:13:55 -0500 Subject: [PATCH 01/26] Semi-Kill #9531 --- packages/backend/src/remote/activitypub/models/note.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/backend/src/remote/activitypub/models/note.ts b/packages/backend/src/remote/activitypub/models/note.ts index afb3af6cbc..e5f3853bdb 100644 --- a/packages/backend/src/remote/activitypub/models/note.ts +++ b/packages/backend/src/remote/activitypub/models/note.ts @@ -115,6 +115,16 @@ export async function createNote( logger.info(`Creating the Note: ${note.id}`); + // Skip if note is made before 2007 (1yr before Fedi was created) + if (note.published) { + const DateChecker = new Date(note.published) + if (DateChecker.getFullYear() < 2007) { + logger.warn('Note somehow made before Activitypub was created; discarding'); + return null; + } + } + + // Fetch author const actor = (await resolvePerson( getOneApId(note.attributedTo), From f9fc1d7137ac1258fc730df5049eaf9da07911cb Mon Sep 17 00:00:00 2001 From: Kio-td Date: Sat, 11 Feb 2023 06:26:05 -0500 Subject: [PATCH 02/26] Discard if 3 days in the future --- packages/backend/src/remote/activitypub/models/note.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/backend/src/remote/activitypub/models/note.ts b/packages/backend/src/remote/activitypub/models/note.ts index e5f3853bdb..ee9ccf52aa 100644 --- a/packages/backend/src/remote/activitypub/models/note.ts +++ b/packages/backend/src/remote/activitypub/models/note.ts @@ -116,12 +116,19 @@ export async function createNote( logger.info(`Creating the Note: ${note.id}`); // Skip if note is made before 2007 (1yr before Fedi was created) + // OR skip if note is made 3 days in advance if (note.published) { const DateChecker = new Date(note.published) + const FutureCheck = new Date() + FutureCheck.setDate(FutureCheck.getDate() + 3) // Allow some wiggle room for misconfigured hosts if (DateChecker.getFullYear() < 2007) { logger.warn('Note somehow made before Activitypub was created; discarding'); return null; } + if (DateChecker < FutureCheck) { + logger.warn('Note somehow made after today; discarding') + return null; + } } From cd6a1d09f5e807ed319046d81bb7edc53f53fa11 Mon Sep 17 00:00:00 2001 From: Kio-td Date: Sat, 11 Feb 2023 07:18:56 -0500 Subject: [PATCH 03/26] Fix bad math --- packages/backend/src/remote/activitypub/models/note.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/backend/src/remote/activitypub/models/note.ts b/packages/backend/src/remote/activitypub/models/note.ts index 3c438aa2fc..e643e24c9f 100644 --- a/packages/backend/src/remote/activitypub/models/note.ts +++ b/packages/backend/src/remote/activitypub/models/note.ts @@ -135,7 +135,7 @@ export async function createNote( logger.warn('Note somehow made before Activitypub was created; discarding'); return null; } - if (DateChecker < FutureCheck) { + if (DateChecker > FutureCheck) { logger.warn('Note somehow made after today; discarding') return null; } From 7a88a0dedd4684827fd2718cfa091551b0690f36 Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Fri, 17 Feb 2023 13:01:14 -0800 Subject: [PATCH 04/26] chore: formatting --- packages/backend/src/misc/reaction-lib.ts | 33 ++++++++++--------- .../server/api/endpoints/channels/followed.ts | 16 ++++++--- 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/packages/backend/src/misc/reaction-lib.ts b/packages/backend/src/misc/reaction-lib.ts index 7d78904bba..e25b2d6614 100644 --- a/packages/backend/src/misc/reaction-lib.ts +++ b/packages/backend/src/misc/reaction-lib.ts @@ -5,17 +5,17 @@ import { toPunyNullable } from "./convert-host.js"; import { IsNull } from "typeorm"; const legacies = new Map([ - ['like', '👍'], - ['love', '❤️'], - ['laugh', '😆'], - ['hmm', '🤔'], - ['surprise', '😮'], - ['congrats', '🎉'], - ['angry', '💢'], - ['confused', '😥'], - ['rip', '😇'], - ['pudding', '🍮'], - ['star', '⭐'], + ["like", "👍"], + ["love", "❤️"], + ["laugh", "😆"], + ["hmm", "🤔"], + ["surprise", "😮"], + ["congrats", "🎉"], + ["angry", "💢"], + ["confused", "😥"], + ["rip", "😇"], + ["pudding", "🍮"], + ["star", "⭐"], ]); export async function getFallbackReaction() { @@ -42,7 +42,10 @@ export function convertLegacyReactions(reactions: Record) { if (emoji) { _reactions.set(emoji, (_reactions.get(emoji) || 0) + reactions[reaction]); } else { - _reactions.set(reaction, (_reactions.get(reaction) || 0) + reactions[reaction]); + _reactions.set( + reaction, + (_reactions.get(reaction) || 0) + reactions[reaction], + ); } } @@ -127,7 +130,7 @@ export function decodeReaction(str: string): DecodedReaction { } export function convertLegacyReaction(reaction: string): string { - const decoded = decodeReaction(reaction).reaction; - if (legacies.has(decoded)) return legacies.get(decoded)!; - return decoded; + const decoded = decodeReaction(reaction).reaction; + if (legacies.has(decoded)) return legacies.get(decoded)!; + return decoded; } diff --git a/packages/backend/src/server/api/endpoints/channels/followed.ts b/packages/backend/src/server/api/endpoints/channels/followed.ts index f9e61222fc..993a211f7e 100644 --- a/packages/backend/src/server/api/endpoints/channels/followed.ts +++ b/packages/backend/src/server/api/endpoints/channels/followed.ts @@ -32,17 +32,23 @@ export const paramDef = { } as const; export default define(meta, paramDef, async (ps, me) => { - const query = ChannelFollowings.createQueryBuilder('following').andWhere({ followerId: me.id }); + const query = ChannelFollowings.createQueryBuilder("following").andWhere({ + followerId: me.id, + }); if (ps.sinceId) { - query.andWhere('following."followeeId" > :sinceId', { sinceId: ps.sinceId }); + query.andWhere('following."followeeId" > :sinceId', { + sinceId: ps.sinceId, + }); } if (ps.untilId) { - query.andWhere('following."followeeId" < :untilId', { untilId: ps.untilId }); + query.andWhere('following."followeeId" < :untilId', { + untilId: ps.untilId, + }); } if (ps.sinceId && !ps.untilId) { - query.orderBy('following."followeeId"', 'ASC'); + query.orderBy('following."followeeId"', "ASC"); } else { - query.orderBy('following."followeeId"', 'DESC'); + query.orderBy('following."followeeId"', "DESC"); } const followings = await query.take(ps.limit).getMany(); From 22ce676cf94cc6d6c19febbe841592aef6bc3e6a Mon Sep 17 00:00:00 2001 From: CutestNekoAqua Date: Sat, 18 Feb 2023 17:14:16 +0100 Subject: [PATCH 05/26] make relationshiops work --- .../backend/src/server/api/mastodon/endpoints/account.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/backend/src/server/api/mastodon/endpoints/account.ts b/packages/backend/src/server/api/mastodon/endpoints/account.ts index f395c5a9c5..a93b1f5962 100644 --- a/packages/backend/src/server/api/mastodon/endpoints/account.ts +++ b/packages/backend/src/server/api/mastodon/endpoints/account.ts @@ -98,7 +98,7 @@ export function apiAccountMastodon(router: Router): void { ctx.body = e.response.data; } }); - router.get<{ Params: { id: string } }>("/v1/accounts/:id", async (ctx) => { + router.get<{ Params: { id: string } }>("/v1/accounts/:id(^.*\\d.*$)", async (ctx) => { const BASE_URL = `${ctx.protocol}://${ctx.hostname}`; const accessTokens = ctx.headers.authorization; const client = getClient(BASE_URL, accessTokens); @@ -304,11 +304,12 @@ export function apiAccountMastodon(router: Router): void { const client = getClient(BASE_URL, accessTokens); let users; try { - const idsRaw = ctx.request.body ? ["id[]"] : null; + // TODO: this should be body + const idsRaw = ctx.request.query ? ["id[]"] : null; const ids = typeof idsRaw === "string" ? [idsRaw] : idsRaw; users = ids; relationshopModel.id = idsRaw?.toString() || "1"; - if (!(idsRaw && ids)) { + if (!idsRaw) { ctx.body = [relationshopModel]; return; } From d418fee933d6cf44d5ed188062cc1e68706486a6 Mon Sep 17 00:00:00 2001 From: CutestNekoAqua Date: Sat, 18 Feb 2023 17:22:43 +0100 Subject: [PATCH 06/26] debug print users --- .../backend/src/server/api/mastodon/endpoints/account.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/server/api/mastodon/endpoints/account.ts b/packages/backend/src/server/api/mastodon/endpoints/account.ts index a93b1f5962..25a1abcc03 100644 --- a/packages/backend/src/server/api/mastodon/endpoints/account.ts +++ b/packages/backend/src/server/api/mastodon/endpoints/account.ts @@ -317,9 +317,11 @@ export function apiAccountMastodon(router: Router): void { ctx.body = data.data; } catch (e: any) { console.error(e); - console.error(e.response.data); + let data = e.response.data; + data.users = users; + console.error(data); ctx.status = 401; - ctx.body = e.response.data; + ctx.body = data; } }); router.get("/v1/bookmarks", async (ctx) => { From 0c73344966111a7782cea698ecd6a73703eb7b10 Mon Sep 17 00:00:00 2001 From: CutestNekoAqua Date: Sat, 18 Feb 2023 17:24:58 +0100 Subject: [PATCH 07/26] fix oopsie --- packages/backend/src/server/api/mastodon/endpoints/account.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/backend/src/server/api/mastodon/endpoints/account.ts b/packages/backend/src/server/api/mastodon/endpoints/account.ts index 25a1abcc03..8ff7ba0085 100644 --- a/packages/backend/src/server/api/mastodon/endpoints/account.ts +++ b/packages/backend/src/server/api/mastodon/endpoints/account.ts @@ -305,7 +305,7 @@ export function apiAccountMastodon(router: Router): void { let users; try { // TODO: this should be body - const idsRaw = ctx.request.query ? ["id[]"] : null; + const idsRaw = ctx.request.query ? ctx.request.query["id[]"] : null; const ids = typeof idsRaw === "string" ? [idsRaw] : idsRaw; users = ids; relationshopModel.id = idsRaw?.toString() || "1"; From 2d59e363c04512b91aa3992f3b07adbf7eac498b Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Sat, 18 Feb 2023 11:33:25 -0800 Subject: [PATCH 08/26] feat: :sparkles: Show time for users --- locales/en-US.yml | 1 + package.json | 4 +- .../server/api/mastodon/endpoints/account.ts | 31 ++++--- packages/backend/src/server/web/bios.js | 78 ++++++++-------- packages/backend/src/server/web/boot.js | 92 ++++++++++--------- packages/backend/src/server/web/cli.js | 56 +++++------ packages/client/package.json | 9 +- .../src/components/global/MkPageHeader.vue | 2 +- .../client/src/pages/settings/profile.vue | 2 +- packages/client/src/pages/user/home.vue | 19 ++-- pnpm-lock.yaml | 52 +++++------ 11 files changed, 178 insertions(+), 168 deletions(-) diff --git a/locales/en-US.yml b/locales/en-US.yml index 173404e7c4..97f5313c80 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -1400,6 +1400,7 @@ _profile: metadataContent: "Content" changeAvatar: "Change avatar" changeBanner: "Change banner" + locationDescription: "If entered properly, this will display your local time to other users." _exportOrImport: allNotes: "All posts" followingList: "Followed users" diff --git a/package.json b/package.json index dbb304cb96..11a539409e 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,12 @@ { "name": "calckey", - "version": "13.2.0-dev9", + "version": "13.2.0-dev11", "codename": "aqua", "repository": { "type": "git", "url": "https://codeberg.org/calckey/calckey.git" }, - "packageManager": "pnpm@7.27.0", + "packageManager": "pnpm@7.27.1", "private": true, "scripts": { "rebuild": "pnpm run clean && pnpm -r run build && pnpm run gulp", diff --git a/packages/backend/src/server/api/mastodon/endpoints/account.ts b/packages/backend/src/server/api/mastodon/endpoints/account.ts index 8ff7ba0085..5b7df948e3 100644 --- a/packages/backend/src/server/api/mastodon/endpoints/account.ts +++ b/packages/backend/src/server/api/mastodon/endpoints/account.ts @@ -98,20 +98,23 @@ export function apiAccountMastodon(router: Router): void { ctx.body = e.response.data; } }); - router.get<{ Params: { id: string } }>("/v1/accounts/:id(^.*\\d.*$)", async (ctx) => { - const BASE_URL = `${ctx.protocol}://${ctx.hostname}`; - const accessTokens = ctx.headers.authorization; - const client = getClient(BASE_URL, accessTokens); - try { - const data = await client.getAccount(ctx.params.id); - ctx.body = data.data; - } catch (e: any) { - console.error(e); - console.error(e.response.data); - ctx.status = 401; - ctx.body = e.response.data; - } - }); + router.get<{ Params: { id: string } }>( + "/v1/accounts/:id(^.*\\d.*$)", + async (ctx) => { + const BASE_URL = `${ctx.protocol}://${ctx.hostname}`; + const accessTokens = ctx.headers.authorization; + const client = getClient(BASE_URL, accessTokens); + try { + const data = await client.getAccount(ctx.params.id); + ctx.body = data.data; + } catch (e: any) { + console.error(e); + console.error(e.response.data); + ctx.status = 401; + ctx.body = e.response.data; + } + }, + ); router.get<{ Params: { id: string } }>( "/v1/accounts/:id/statuses", async (ctx) => { diff --git a/packages/backend/src/server/web/bios.js b/packages/backend/src/server/web/bios.js index 1acdafd1d5..e715a01068 100644 --- a/packages/backend/src/server/web/bios.js +++ b/packages/backend/src/server/web/bios.js @@ -1,7 +1,7 @@ -'use strict'; +"use strict"; window.onload = async () => { - const account = JSON.parse(localStorage.getItem('account')); + const account = JSON.parse(localStorage.getItem("account")); const i = account.token; const api = (endpoint, data = {}) => { @@ -10,42 +10,44 @@ window.onload = async () => { if (i) data.i = i; // Send request - fetch(endpoint.indexOf('://') > -1 ? endpoint : `/api/${endpoint}`, { - method: 'POST', + fetch(endpoint.indexOf("://") > -1 ? endpoint : `/api/${endpoint}`, { + method: "POST", body: JSON.stringify(data), - credentials: 'omit', - cache: 'no-cache' - }).then(async (res) => { - const body = res.status === 204 ? null : await res.json(); + credentials: "omit", + cache: "no-cache", + }) + .then(async (res) => { + const body = res.status === 204 ? null : await res.json(); - if (res.status === 200) { - resolve(body); - } else if (res.status === 204) { - resolve(); - } else { - reject(body.error); - } - }).catch(reject); + if (res.status === 200) { + resolve(body); + } else if (res.status === 204) { + resolve(); + } else { + reject(body.error); + } + }) + .catch(reject); }); return promise; }; - const content = document.getElementById('content'); + const content = document.getElementById("content"); - document.getElementById('ls').addEventListener('click', () => { - content.innerHTML = ''; + document.getElementById("ls").addEventListener("click", () => { + content.innerHTML = ""; - const lsEditor = document.createElement('div'); - lsEditor.id = 'lsEditor'; + const lsEditor = document.createElement("div"); + lsEditor.id = "lsEditor"; - const adder = document.createElement('div'); - adder.classList.add('adder'); - const addKeyInput = document.createElement('input'); - const addValueTextarea = document.createElement('textarea'); - const addButton = document.createElement('button'); - addButton.textContent = 'Add'; - addButton.addEventListener('click', () => { + const adder = document.createElement("div"); + adder.classList.add("adder"); + const addKeyInput = document.createElement("input"); + const addValueTextarea = document.createElement("textarea"); + const addButton = document.createElement("button"); + addButton.textContent = "Add"; + addButton.addEventListener("click", () => { localStorage.setItem(addKeyInput.value, addValueTextarea.value); location.reload(); }); @@ -57,21 +59,21 @@ window.onload = async () => { for (let i = 0; i < localStorage.length; i++) { const k = localStorage.key(i); - const record = document.createElement('div'); - record.classList.add('record'); - const header = document.createElement('header'); + const record = document.createElement("div"); + record.classList.add("record"); + const header = document.createElement("header"); header.textContent = k; - const textarea = document.createElement('textarea'); + const textarea = document.createElement("textarea"); textarea.textContent = localStorage.getItem(k); - const saveButton = document.createElement('button'); - saveButton.textContent = 'Save'; - saveButton.addEventListener('click', () => { + const saveButton = document.createElement("button"); + saveButton.textContent = "Save"; + saveButton.addEventListener("click", () => { localStorage.setItem(k, textarea.value); location.reload(); }); - const removeButton = document.createElement('button'); - removeButton.textContent = 'Remove'; - removeButton.addEventListener('click', () => { + const removeButton = document.createElement("button"); + removeButton.textContent = "Remove"; + removeButton.addEventListener("click", () => { localStorage.removeItem(k); location.reload(); }); diff --git a/packages/backend/src/server/web/boot.js b/packages/backend/src/server/web/boot.js index f4e0707a93..e7e859d20c 100644 --- a/packages/backend/src/server/web/boot.js +++ b/packages/backend/src/server/web/boot.js @@ -9,120 +9,122 @@ * 注: webpackは介さないため、このファイルではrequireやimportは使えません。 */ -'use strict'; +"use strict"; // ブロックの中に入れないと、定義した変数がブラウザのグローバルスコープに登録されてしまい邪魔なので (async () => { window.onerror = (e) => { console.error(e); - renderError('SOMETHING_HAPPENED', e); + renderError("SOMETHING_HAPPENED", e); }; window.onunhandledrejection = (e) => { console.error(e); - renderError('SOMETHING_HAPPENED_IN_PROMISE', e); + renderError("SOMETHING_HAPPENED_IN_PROMISE", e); }; //#region Detect language & fetch translations - const v = localStorage.getItem('v') || VERSION; + const v = localStorage.getItem("v") || VERSION; const supportedLangs = LANGS; - let lang = localStorage.getItem('lang'); + let lang = localStorage.getItem("lang"); if (lang == null || !supportedLangs.includes(lang)) { if (supportedLangs.includes(navigator.language)) { lang = navigator.language; } else { - lang = supportedLangs.find(x => x.split('-')[0] === navigator.language); + lang = supportedLangs.find((x) => x.split("-")[0] === navigator.language); // Fallback - if (lang == null) lang = 'en-US'; + if (lang == null) lang = "en-US"; } } const res = await fetch(`/assets/locales/${lang}.${v}.json`); if (res.status === 200) { - localStorage.setItem('lang', lang); - localStorage.setItem('locale', await res.text()); - localStorage.setItem('localeVersion', v); + localStorage.setItem("lang", lang); + localStorage.setItem("locale", await res.text()); + localStorage.setItem("localeVersion", v); } else { await checkUpdate(); - renderError('LOCALE_FETCH'); + renderError("LOCALE_FETCH"); return; } //#endregion //#region Script function importAppScript() { - import(`/assets/${CLIENT_ENTRY}`) - .catch(async e => { - await checkUpdate(); - console.error(e); - renderError('APP_IMPORT', e); - }); + import(`/assets/${CLIENT_ENTRY}`).catch(async (e) => { + await checkUpdate(); + console.error(e); + renderError("APP_IMPORT", e); + }); } // タイミングによっては、この時点でDOMの構築が済んでいる場合とそうでない場合とがある - if (document.readyState !== 'loading') { + if (document.readyState !== "loading") { importAppScript(); } else { - window.addEventListener('DOMContentLoaded', () => { + window.addEventListener("DOMContentLoaded", () => { importAppScript(); }); } //#endregion //#region Theme - const theme = localStorage.getItem('theme'); + const theme = localStorage.getItem("theme"); if (theme) { for (const [k, v] of Object.entries(JSON.parse(theme))) { document.documentElement.style.setProperty(`--${k}`, v.toString()); // HTMLの theme-color 適用 - if (k === 'htmlThemeColor') { + if (k === "htmlThemeColor") { for (const tag of document.head.children) { - if (tag.tagName === 'META' && tag.getAttribute('name') === 'theme-color') { - tag.setAttribute('content', v); + if ( + tag.tagName === "META" && + tag.getAttribute("name") === "theme-color" + ) { + tag.setAttribute("content", v); break; } } } } } - const colorSchema = localStorage.getItem('colorSchema'); + const colorSchema = localStorage.getItem("colorSchema"); if (colorSchema) { - document.documentElement.style.setProperty('color-schema', colorSchema); + document.documentElement.style.setProperty("color-schema", colorSchema); } //#endregion - const fontSize = localStorage.getItem('fontSize'); + const fontSize = localStorage.getItem("fontSize"); if (fontSize) { - document.documentElement.classList.add('f-' + fontSize); + document.documentElement.classList.add("f-" + fontSize); } - const useSystemFont = localStorage.getItem('useSystemFont'); + const useSystemFont = localStorage.getItem("useSystemFont"); if (useSystemFont) { - document.documentElement.classList.add('useSystemFont'); + document.documentElement.classList.add("useSystemFont"); } - const wallpaper = localStorage.getItem('wallpaper'); + const wallpaper = localStorage.getItem("wallpaper"); if (wallpaper) { document.documentElement.style.backgroundImage = `url(${wallpaper})`; } - const customCss = localStorage.getItem('customCss'); + const customCss = localStorage.getItem("customCss"); if (customCss && customCss.length > 0) { - const style = document.createElement('style'); + const style = document.createElement("style"); style.innerHTML = customCss; document.head.appendChild(style); } async function addStyle(styleText) { - let css = document.createElement('style'); + let css = document.createElement("style"); css.appendChild(document.createTextNode(styleText)); document.head.appendChild(css); } function renderError(code, details) { - let errorsElement = document.getElementById('errors'); + let errorsElement = document.getElementById("errors"); if (!errorsElement) { document.body.innerHTML = ` @@ -158,9 +160,9 @@
`; - errorsElement = document.getElementById('errors'); + errorsElement = document.getElementById("errors"); } - const detailsElement = document.createElement('details'); + const detailsElement = document.createElement("details"); detailsElement.innerHTML = `
@@ -278,25 +280,25 @@ details { width: 50%; } - `) + `); } async function checkUpdate() { try { - const res = await fetch('/api/meta', { - method: 'POST', - cache: 'no-cache' + const res = await fetch("/api/meta", { + method: "POST", + cache: "no-cache", }); const meta = await res.json(); if (meta.version != v) { - localStorage.setItem('v', meta.version); + localStorage.setItem("v", meta.version); refresh(); } } catch (e) { console.error(e); - renderError('UPDATE_CHECK', e); + renderError("UPDATE_CHECK", e); throw e; } } @@ -304,9 +306,9 @@ function refresh() { // Clear cache (service worker) try { - navigator.serviceWorker.controller.postMessage('clear'); - navigator.serviceWorker.getRegistrations().then(registrations => { - registrations.forEach(registration => registration.unregister()); + navigator.serviceWorker.controller.postMessage("clear"); + navigator.serviceWorker.getRegistrations().then((registrations) => { + registrations.forEach((registration) => registration.unregister()); }); } catch (e) { console.error(e); diff --git a/packages/backend/src/server/web/cli.js b/packages/backend/src/server/web/cli.js index 3dff1d4860..290453f7e0 100644 --- a/packages/backend/src/server/web/cli.js +++ b/packages/backend/src/server/web/cli.js @@ -1,51 +1,53 @@ -'use strict'; +"use strict"; window.onload = async () => { - const account = JSON.parse(localStorage.getItem('account')); + const account = JSON.parse(localStorage.getItem("account")); const i = account.token; const api = (endpoint, data = {}) => { const promise = new Promise((resolve, reject) => { // Append a credential if (i) data.i = i; - + // Send request - fetch(endpoint.indexOf('://') > -1 ? endpoint : `/api/${endpoint}`, { - method: 'POST', + fetch(endpoint.indexOf("://") > -1 ? endpoint : `/api/${endpoint}`, { + method: "POST", body: JSON.stringify(data), - credentials: 'omit', - cache: 'no-cache' - }).then(async (res) => { - const body = res.status === 204 ? null : await res.json(); - - if (res.status === 200) { - resolve(body); - } else if (res.status === 204) { - resolve(); - } else { - reject(body.error); - } - }).catch(reject); + credentials: "omit", + cache: "no-cache", + }) + .then(async (res) => { + const body = res.status === 204 ? null : await res.json(); + + if (res.status === 200) { + resolve(body); + } else if (res.status === 204) { + resolve(); + } else { + reject(body.error); + } + }) + .catch(reject); }); - + return promise; }; - document.getElementById('submit').addEventListener('click', () => { - api('notes/create', { - text: document.getElementById('text').value + document.getElementById("submit").addEventListener("click", () => { + api("notes/create", { + text: document.getElementById("text").value, }).then(() => { location.reload(); }); }); - api('notes/timeline').then(notes => { - const tl = document.getElementById('tl'); + api("notes/timeline").then((notes) => { + const tl = document.getElementById("tl"); for (const note of notes) { - const el = document.createElement('div'); - const name = document.createElement('header'); + const el = document.createElement("div"); + const name = document.createElement("header"); name.textContent = `${note.user.name} @${note.user.username}`; - const text = document.createElement('div'); + const text = document.createElement("div"); text.textContent = `${note.text}`; el.appendChild(name); el.appendChild(text); diff --git a/packages/client/package.json b/packages/client/package.json index fe6288406b..4289d80497 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -6,13 +6,9 @@ "build": "pnpm vite build", "lint": "pnpm rome check \"src/**/*.{ts,vue}\"" }, - "dependencies": { - "@khmyznikov/pwa-install": "^0.2.0", - "chartjs-chart-matrix": "^2.0.1", - "gsap": "^3.11.4" - }, "devDependencies": { "@discordapp/twemoji": "14.0.2", + "@khmyznikov/pwa-install": "^0.2.0", "@rollup/plugin-alias": "3.1.9", "@rollup/plugin-json": "4.1.0", "@rollup/pluginutils": "^4.2.1", @@ -40,6 +36,8 @@ "chartjs-adapter-date-fns": "2.0.1", "chartjs-plugin-gradient": "0.5.1", "chartjs-plugin-zoom": "1.2.1", + "chartjs-chart-matrix": "^2.0.1", + "city-timezones": "^1.2.1", "compare-versions": "5.0.3", "cropperjs": "2.0.0-beta.2", "cross-env": "7.0.3", @@ -47,6 +45,7 @@ "date-fns": "2.29.3", "escape-regexp": "0.0.1", "eventemitter3": "4.0.7", + "gsap": "^3.11.4", "idb-keyval": "6.2.0", "insert-text-at-cursor": "0.3.0", "json5": "2.2.3", diff --git a/packages/client/src/components/global/MkPageHeader.vue b/packages/client/src/components/global/MkPageHeader.vue index 8fa3edfe1e..5eaa5e4fee 100644 --- a/packages/client/src/components/global/MkPageHeader.vue +++ b/packages/client/src/components/global/MkPageHeader.vue @@ -143,7 +143,7 @@ let ro: ResizeObserver | null; onMounted(() => { calcBg(); globalEvents.on('themeChanged', calcBg); - + watch(() => [props.tab, props.tabs], () => { nextTick(() => { const tabEl = tabRefs[props.tab]; diff --git a/packages/client/src/pages/settings/profile.vue b/packages/client/src/pages/settings/profile.vue index 82b95718b1..e201ed2d8a 100644 --- a/packages/client/src/pages/settings/profile.vue +++ b/packages/client/src/pages/settings/profile.vue @@ -24,6 +24,7 @@ + @@ -76,7 +77,6 @@ import FormSelect from '@/components/form/select.vue'; import FormSplit from '@/components/form/split.vue'; import FormFolder from '@/components/form/folder.vue'; import FormSlot from '@/components/form/slot.vue'; -import { host } from '@/config'; import { selectFile } from '@/scripts/select-file'; import * as os from '@/os'; import { i18n } from '@/i18n'; diff --git a/packages/client/src/pages/user/home.vue b/packages/client/src/pages/user/home.vue index 23d8aa8427..0fe4774bd7 100644 --- a/packages/client/src/pages/user/home.vue +++ b/packages/client/src/pages/user/home.vue @@ -56,7 +56,7 @@
{{ i18n.ts.location }}
-
{{ user.location }}
+
{{ user.location }}{{ timeForThem }}
{{ i18n.ts.birthday }}
@@ -117,27 +117,24 @@ - diff --git a/packages/client/src/components/MkPostFormDialog.vue b/packages/client/src/components/MkPostFormDialog.vue index 6dabb1db14..479d5dd06b 100644 --- a/packages/client/src/components/MkPostFormDialog.vue +++ b/packages/client/src/components/MkPostFormDialog.vue @@ -1,19 +1,46 @@ + + + + - + const props = defineProps<{ + reply?: misskey.entities.Note; + renote?: misskey.entities.Note; + channel?: any; // TODO + mention?: misskey.entities.User; + specified?: misskey.entities.User; + initialText?: string; + initialVisibility?: typeof misskey.noteVisibilities; + initialFiles?: misskey.entities.DriveFile[]; + initialLocalOnly?: boolean; + initialVisibleUsers?: misskey.entities.User[]; + initialNote?: misskey.entities.Note; + instant?: boolean; + fixed?: boolean; + autofocus?: boolean; + }>(); + + const emit = defineEmits<{ + (ev: 'closed'): void; + }>(); + + let modal = $shallowRef>(); + let form = $shallowRef>(); + + function onPosted() { + modal.close({ + useSendAnimation: true, + }); + } + + function onModalClosed() { + emit('closed'); + } + From 9c5dc7b3f22ad8cc12aaade6212873db0f765ba5 Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Sat, 18 Feb 2023 15:34:41 -0800 Subject: [PATCH 13/26] fix: dialog --- packages/client/src/components/MkDialog.vue | 189 ++++++++++---------- 1 file changed, 97 insertions(+), 92 deletions(-) diff --git a/packages/client/src/components/MkDialog.vue b/packages/client/src/components/MkDialog.vue index e01b0a3325..ec55d15f70 100644 --- a/packages/client/src/components/MkDialog.vue +++ b/packages/client/src/components/MkDialog.vue @@ -1,51 +1,51 @@ - From 0f9daa4ac4e7d4bfd878273940e89f9eb310bc93 Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Sat, 18 Feb 2023 15:48:46 -0800 Subject: [PATCH 14/26] fix? --- packages/client/src/components/MkModal.vue | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/client/src/components/MkModal.vue b/packages/client/src/components/MkModal.vue index 4048177a63..840a1aee25 100644 --- a/packages/client/src/components/MkModal.vue +++ b/packages/client/src/components/MkModal.vue @@ -414,6 +414,17 @@ defineExpose({ -webkit-mask-image: linear-gradient(0deg, rgba(0,0,0,0) 0%, rgba(0,0,0,1) 16px, rgba(0,0,0,1) calc(100% - 16px), rgba(0,0,0,0) 100%); mask-image: linear-gradient(0deg, rgba(0,0,0,0) 0%, rgba(0,0,0,1) 16px, rgba(0,0,0,1) calc(100% - 16px), rgba(0,0,0,0) 100%); } + + > ::v-deep(*) { + margin: auto; + } + + &.top { + > ::v-deep(*) { + margin-top: 0; + } + } + } } @@ -441,6 +452,10 @@ defineExpose({ left: 0; right: 0; margin: auto; + + > ::v-deep(*) { + margin: auto; + } } } } From 3e87ca0e94ee09c7eb6db85f9ede566eedbafca6 Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Sat, 18 Feb 2023 15:53:19 -0800 Subject: [PATCH 15/26] formatting --- .../src/components/MkPostFormDialog.vue | 72 +++++++++---------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/packages/client/src/components/MkPostFormDialog.vue b/packages/client/src/components/MkPostFormDialog.vue index 479d5dd06b..147ba9542b 100644 --- a/packages/client/src/components/MkPostFormDialog.vue +++ b/packages/client/src/components/MkPostFormDialog.vue @@ -2,45 +2,45 @@ - + - +function onModalClosed() { + emit('closed'); +} + From 7132ad2285beaa08bc3adde85439e246c21e59b1 Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Sat, 18 Feb 2023 16:16:24 -0800 Subject: [PATCH 16/26] fix?? --- packages/client/src/components/MkModal.vue | 14 +++---- .../client/src/components/MkModalWindow.vue | 38 ++++++++++--------- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/packages/client/src/components/MkModal.vue b/packages/client/src/components/MkModal.vue index 840a1aee25..b88dee380e 100644 --- a/packages/client/src/components/MkModal.vue +++ b/packages/client/src/components/MkModal.vue @@ -7,9 +7,9 @@ :leave-to-class="$style['transition_' + transitionName + '_leaveTo']" :duration="transitionDuration" appear @after-leave="emit('closed')" @enter="emit('opening')" @after-enter="onOpened" > -
+
-
+
@@ -33,7 +33,7 @@ function getFixedContainer(el: Element | null): Element | null { } } -type ModalTypes = 'popup' | 'dialog' | 'drawer'; +type ModalTypes = 'popup' | 'dialog' | 'dialog:top' | 'drawer'; const props = withDefaults(defineProps<{ manualShowing?: boolean | null; @@ -194,21 +194,21 @@ const align = () => { } } else { // 画面から横にはみ出る場合 - if (left + width - window.pageXOffset > window.innerWidth) { - left = window.innerWidth - width + window.pageXOffset - 1; + if (left + width - window.scrollX > window.innerWidth) { + left = window.innerWidth - width + window.scrollX - 1; } const underSpace = (window.innerHeight - MARGIN) - (top - window.pageYOffset); const upperSpace = (srcRect.top - MARGIN); // 画面から縦にはみ出る場合 - if (top + height - window.pageYOffset > (window.innerHeight - MARGIN)) { + if (top + height - window.scrollY > (window.innerHeight - MARGIN)) { if (props.noOverlap && props.anchor.x === 'center') { if (underSpace >= (upperSpace / 3)) { maxHeight = underSpace; } else { maxHeight = upperSpace; - top = window.pageYOffset + ((upperSpace + MARGIN) - height); + top = window.scrollY + ((upperSpace + MARGIN) - height); } } else { top = (window.innerHeight - MARGIN) - height + window.pageYOffset - 1; diff --git a/packages/client/src/components/MkModalWindow.vue b/packages/client/src/components/MkModalWindow.vue index 6663824666..2765a99270 100644 --- a/packages/client/src/components/MkModalWindow.vue +++ b/packages/client/src/components/MkModalWindow.vue @@ -1,19 +1,19 @@ From 302e452572128deefc6bc07d1f80836f1b6a7319 Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Sat, 18 Feb 2023 19:48:25 -0800 Subject: [PATCH 20/26] fix --- packages/client/src/components/MkDialog.vue | 2 +- .../src/components/global/MkLoading.vue | 8 +++ packages/client/src/os.ts | 51 ++++++++++++------- 3 files changed, 42 insertions(+), 19 deletions(-) diff --git a/packages/client/src/components/MkDialog.vue b/packages/client/src/components/MkDialog.vue index ec55d15f70..1bcfa81a5f 100644 --- a/packages/client/src/components/MkDialog.vue +++ b/packages/client/src/components/MkDialog.vue @@ -9,7 +9,7 @@ - +
diff --git a/packages/client/src/components/global/MkLoading.vue b/packages/client/src/components/global/MkLoading.vue index 362484f5fc..dc61e577b1 100644 --- a/packages/client/src/components/global/MkLoading.vue +++ b/packages/client/src/components/global/MkLoading.vue @@ -15,10 +15,12 @@ const props = withDefaults(defineProps<{ inline?: boolean; colored?: boolean; mini?: boolean; + em?: boolean; }>(), { inline: false, colored: true, mini: false, + em: false, }); @@ -70,6 +72,12 @@ const props = withDefaults(defineProps<{ padding: 16px; --size: 32px; } + &.em { + display: inline-block; + vertical-align: middle; + padding: 0; + --size: 1em; + } } .container { diff --git a/packages/client/src/os.ts b/packages/client/src/os.ts index d3516bf4ca..0e6bdf3182 100644 --- a/packages/client/src/os.ts +++ b/packages/client/src/os.ts @@ -7,8 +7,8 @@ import * as Misskey from "calckey-js"; import { apiUrl, url } from "@/config"; import MkPostFormDialog from "@/components/MkPostFormDialog.vue"; import MkWaitingDialog from "@/components/MkWaitingDialog.vue"; -import MkToast from '@/components/MkToast.vue'; -import MkDialog from '@/components/MkDialog.vue'; +import MkToast from "@/components/MkToast.vue"; +import MkDialog from "@/components/MkDialog.vue"; import { MenuItem } from "@/types/menu"; import { $i } from "@/account"; @@ -248,41 +248,56 @@ export function modalPageWindow(path: string) { } export function toast(message: string) { - popup(MkToast, { - message, - }, {}, 'closed'); + popup( + MkToast, + { + message, + }, + {}, + "closed", + ); } export function alert(props: { - type?: 'error' | 'info' | 'success' | 'warning' | 'waiting' | 'question'; + type?: "error" | "info" | "success" | "warning" | "waiting" | "question"; title?: string | null; text?: string | null; }): Promise { return new Promise((resolve, reject) => { - popup(MkDialog, props, { - done: result => { - resolve(); + popup( + MkDialog, + props, + { + done: (result) => { + resolve(); + }, }, - }, 'closed'); + "closed", + ); }); } export function confirm(props: { - type: 'error' | 'info' | 'success' | 'warning' | 'waiting' | 'question'; + type: "error" | "info" | "success" | "warning" | "waiting" | "question"; title?: string | null; text?: string | null; okText?: string; cancelText?: string; }): Promise<{ canceled: boolean }> { return new Promise((resolve, reject) => { - popup(MkDialog, { - ...props, - showCancelButton: true, - }, { - done: result => { - resolve(result ? result : { canceled: true }); + popup( + MkDialog, + { + ...props, + showCancelButton: true, }, - }, 'closed'); + { + done: (result) => { + resolve(result ? result : { canceled: true }); + }, + }, + "closed", + ); }); } From cc7be70bdf1a522ce99a2c34b5a2025f2d8c7b59 Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Sat, 18 Feb 2023 19:55:18 -0800 Subject: [PATCH 21/26] fix --- .../client/src/components/MkWaitingDialog.vue | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/packages/client/src/components/MkWaitingDialog.vue b/packages/client/src/components/MkWaitingDialog.vue index dfc5115cad..00d34e9495 100644 --- a/packages/client/src/components/MkWaitingDialog.vue +++ b/packages/client/src/components/MkWaitingDialog.vue @@ -1,18 +1,18 @@ - From b8499df5eb10f0f4c26ee94dc7d5039abc904349 Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Sat, 18 Feb 2023 19:58:42 -0800 Subject: [PATCH 22/26] fix MkUpdated --- packages/client/src/components/MkUpdated.vue | 42 ++++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/packages/client/src/components/MkUpdated.vue b/packages/client/src/components/MkUpdated.vue index 6f5ca6618b..d1df6af4c1 100644 --- a/packages/client/src/components/MkUpdated.vue +++ b/packages/client/src/components/MkUpdated.vue @@ -1,15 +1,15 @@ @@ -39,7 +39,8 @@ console.log(data); From 1d2e638571b769737c0f15a79337ef716b8a2796 Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Sat, 18 Feb 2023 20:01:00 -0800 Subject: [PATCH 23/26] style --- packages/client/src/components/MkModal.vue | 4 ++-- .../client/src/pages/admin/overview.federation.vue | 4 ++-- packages/client/src/pages/admin/overview.stats.vue | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/client/src/components/MkModal.vue b/packages/client/src/components/MkModal.vue index b88dee380e..80cfaf8da4 100644 --- a/packages/client/src/components/MkModal.vue +++ b/packages/client/src/components/MkModal.vue @@ -341,12 +341,12 @@ defineExpose({ .transition_modal-popup_enterActive, .transition_modal-popup_leaveActive { > .bg { - transition: opacity 0.1s !important; + transition: opacity 0.2s !important; } > .content { transform-origin: var(--transformOrigin); - transition: opacity 0.1s cubic-bezier(0, 0, 0.2, 1), transform 0.1s cubic-bezier(0, 0, 0.2, 1) !important; + transition: opacity 0.2s cubic-bezier(0, 0, 0.2, 1), transform 0.2s cubic-bezier(0, 0, 0.2, 1) !important; } } .transition_modal-popup_enterFrom, diff --git a/packages/client/src/pages/admin/overview.federation.vue b/packages/client/src/pages/admin/overview.federation.vue index 961837b226..f47632d40f 100644 --- a/packages/client/src/pages/admin/overview.federation.vue +++ b/packages/client/src/pages/admin/overview.federation.vue @@ -147,14 +147,14 @@ onMounted(async () => { &.sub { > .icon { - background: #907aa955; + background: #907aa922; color: #c4a7e7; } } &.pub { > .icon { - background: #56949f55; + background: #56949f22; color: #9ccfd8; } } diff --git a/packages/client/src/pages/admin/overview.stats.vue b/packages/client/src/pages/admin/overview.stats.vue index 0868cba3d1..91ab737830 100644 --- a/packages/client/src/pages/admin/overview.stats.vue +++ b/packages/client/src/pages/admin/overview.stats.vue @@ -106,35 +106,35 @@ onMounted(async () => { &.users { > .icon { - background: #56949f55; + background: #56949f22; color: #9ccfd8; } } &.notes { > .icon { - background: #28698355; + background: #28698322; color: #31748f; } } &.instances { > .icon { - background: #d7827e55; + background: #d7827e22; color: #ebbcba; } } &.emojis { > .icon { - background: #ea9d3455; + background: #ea9d3422; color: #f6c177; } } &.online { > .icon { - background: #907aa955; + background: #907aa922; color: #c4a7e7; } } From 19c88fc68bca7ce5afa20185d8b316bdec02a2af Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Sat, 18 Feb 2023 20:02:58 -0800 Subject: [PATCH 24/26] fix broken style --- packages/client/src/components/MkUpdated.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/client/src/components/MkUpdated.vue b/packages/client/src/components/MkUpdated.vue index d1df6af4c1..a3fc37751a 100644 --- a/packages/client/src/components/MkUpdated.vue +++ b/packages/client/src/components/MkUpdated.vue @@ -63,7 +63,7 @@ console.log(data); margin: 8px 0 0 0; } -> .releaseNotes { +.releaseNotes { > img { border-radius: 10px; } From 0a3e39b6ec048dc6cb448a60dd86ea0d4cdccc68 Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Sat, 18 Feb 2023 20:09:14 -0800 Subject: [PATCH 25/26] testing --- packages/client/src/components/MkUpdated.vue | 4 +++- packages/client/src/init.ts | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/client/src/components/MkUpdated.vue b/packages/client/src/components/MkUpdated.vue index a3fc37751a..640b722d22 100644 --- a/packages/client/src/components/MkUpdated.vue +++ b/packages/client/src/components/MkUpdated.vue @@ -15,6 +15,7 @@ -