From 21c1e086f9aaf2d1c200c50f589c7238e6892140 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 3 Jan 2023 08:26:39 +0900 Subject: [PATCH 01/24] :art: --- packages/frontend/src/ui/universal.vue | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/frontend/src/ui/universal.vue b/packages/frontend/src/ui/universal.vue index 865616f192..9f1324313e 100644 --- a/packages/frontend/src/ui/universal.vue +++ b/packages/frontend/src/ui/universal.vue @@ -287,7 +287,7 @@ const wallpaper = localStorage.getItem('wallpaper') != null; z-index: 1000; bottom: 0; left: 0; - padding: 12px 12px max(12px, calc(env(safe-area-inset-bottom, 0px) + 8px)) 12px; + padding: 12px 12px max(12px, env(safe-area-inset-bottom, 0px)) 12px; display: grid; grid-template-columns: 1fr 1fr 1fr 1fr 1fr; grid-gap: 8px; @@ -333,6 +333,11 @@ const wallpaper = localStorage.getItem('wallpaper') != null; opacity: 0.5; } } + + &.post { + background: linear-gradient(90deg, var(--buttonGradateA), var(--buttonGradateB)); + color: var(--fgOnAccent); + } } } From 771348e887058151ca35aead73ad4b9b625355a8 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 3 Jan 2023 08:29:25 +0900 Subject: [PATCH 02/24] =?UTF-8?q?PV=E9=9B=86=E8=A8=88=E3=81=AF=E3=83=AD?= =?UTF-8?q?=E3=83=BC=E3=82=AB=E3=83=AB=E3=83=A6=E3=83=BC=E3=82=B6=E3=83=BC?= =?UTF-8?q?=E3=81=AE=E3=81=BF=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/src/server/api/endpoints/users/show.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/backend/src/server/api/endpoints/users/show.ts b/packages/backend/src/server/api/endpoints/users/show.ts index 48a6bbf9bc..fcdaeae1c9 100644 --- a/packages/backend/src/server/api/endpoints/users/show.ts +++ b/packages/backend/src/server/api/endpoints/users/show.ts @@ -139,10 +139,12 @@ export default class extends Endpoint { throw new ApiError(meta.errors.noSuchUser); } - if (me == null && ip != null) { - this.perUserPvChart.commitByVisitor(user, ip); - } else if (me && me.id !== user.id) { - this.perUserPvChart.commitByUser(user, me.id); + if (user.host == null) { + if (me == null && ip != null) { + this.perUserPvChart.commitByVisitor(user, ip); + } else if (me && me.id !== user.id) { + this.perUserPvChart.commitByUser(user, me.id); + } } return await this.userEntityService.pack(user, me, { From 7093573f0ccc5bb4b674aca34757cdeb5dd74548 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 3 Jan 2023 08:48:00 +0900 Subject: [PATCH 03/24] drop latestRequestSentAt of instance --- locales/ja-JP.yml | 1 - .../1672703171386-remove-latestRequestSentAt.js | 11 +++++++++++ .../src/core/entities/InstanceEntityService.ts | 3 +-- packages/backend/src/models/entities/Instance.ts | 8 -------- .../src/models/schema/federation-instance.ts | 5 ----- .../queue/processors/DeliverProcessorService.ts | 14 ++++++-------- packages/frontend/src/pages/instance-info.vue | 4 ---- 7 files changed, 18 insertions(+), 28 deletions(-) create mode 100644 packages/backend/migration/1672703171386-remove-latestRequestSentAt.js diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index eb30eed53a..d6a5518196 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -167,7 +167,6 @@ annotation: "注釈" federation: "連合" instances: "インスタンス" registeredAt: "初観測" -latestRequestSentAt: "直近のリクエスト送信" latestRequestReceivedAt: "直近のリクエスト受信" latestStatus: "直近のステータス" storageUsage: "ストレージ使用量" diff --git a/packages/backend/migration/1672703171386-remove-latestRequestSentAt.js b/packages/backend/migration/1672703171386-remove-latestRequestSentAt.js new file mode 100644 index 0000000000..c9b28dd7e1 --- /dev/null +++ b/packages/backend/migration/1672703171386-remove-latestRequestSentAt.js @@ -0,0 +1,11 @@ +export class removeLatestRequestSentAt1672703171386 { + name = 'removeLatestRequestSentAt1672703171386' + + async up(queryRunner) { + await queryRunner.query(`ALTER TABLE "instance" DROP COLUMN "latestRequestSentAt"`); + } + + async down(queryRunner) { + await queryRunner.query(`ALTER TABLE "instance" ADD "latestRequestSentAt" TIMESTAMP WITH TIME ZONE`); + } +} diff --git a/packages/backend/src/core/entities/InstanceEntityService.ts b/packages/backend/src/core/entities/InstanceEntityService.ts index 5a7ceb89a3..7742608b07 100644 --- a/packages/backend/src/core/entities/InstanceEntityService.ts +++ b/packages/backend/src/core/entities/InstanceEntityService.ts @@ -7,8 +7,8 @@ import type { } from '@/models/entities/Blocking.js'; import type { User } from '@/models/entities/User.js'; import type { Instance } from '@/models/entities/Instance.js'; import { MetaService } from '@/core/MetaService.js'; -import { UserEntityService } from './UserEntityService.js'; import { bindThis } from '@/decorators.js'; +import { UserEntityService } from './UserEntityService.js'; @Injectable() export class InstanceEntityService { @@ -33,7 +33,6 @@ export class InstanceEntityService { notesCount: instance.notesCount, followingCount: instance.followingCount, followersCount: instance.followersCount, - latestRequestSentAt: instance.latestRequestSentAt ? instance.latestRequestSentAt.toISOString() : null, lastCommunicatedAt: instance.lastCommunicatedAt.toISOString(), isNotResponding: instance.isNotResponding, isSuspended: instance.isSuspended, diff --git a/packages/backend/src/models/entities/Instance.ts b/packages/backend/src/models/entities/Instance.ts index 7ea9234384..e4e9835ce8 100644 --- a/packages/backend/src/models/entities/Instance.ts +++ b/packages/backend/src/models/entities/Instance.ts @@ -59,14 +59,6 @@ export class Instance { }) public followersCount: number; - /** - * 直近のリクエスト送信日時 - */ - @Column('timestamp with time zone', { - nullable: true, - }) - public latestRequestSentAt: Date | null; - /** * 直近のリクエスト送信時のHTTPステータスコード */ diff --git a/packages/backend/src/models/schema/federation-instance.ts b/packages/backend/src/models/schema/federation-instance.ts index c57b3fec19..739548103a 100644 --- a/packages/backend/src/models/schema/federation-instance.ts +++ b/packages/backend/src/models/schema/federation-instance.ts @@ -32,11 +32,6 @@ export const packedFederationInstanceSchema = { type: 'number', optional: false, nullable: false, }, - latestRequestSentAt: { - type: 'string', - optional: false, nullable: true, - format: 'date-time', - }, lastCommunicatedAt: { type: 'string', optional: false, nullable: false, diff --git a/packages/backend/src/queue/processors/DeliverProcessorService.ts b/packages/backend/src/queue/processors/DeliverProcessorService.ts index 58969d550e..0e74260386 100644 --- a/packages/backend/src/queue/processors/DeliverProcessorService.ts +++ b/packages/backend/src/queue/processors/DeliverProcessorService.ts @@ -15,10 +15,10 @@ import ApRequestChart from '@/core/chart/charts/ap-request.js'; import FederationChart from '@/core/chart/charts/federation.js'; import { StatusError } from '@/misc/status-error.js'; import { UtilityService } from '@/core/UtilityService.js'; +import { bindThis } from '@/decorators.js'; import { QueueLoggerService } from '../QueueLoggerService.js'; import type Bull from 'bull'; import type { DeliverJobData } from '../types.js'; -import { bindThis } from '@/decorators.js'; @Injectable() export class DeliverProcessorService { @@ -85,7 +85,6 @@ export class DeliverProcessorService { // Update stats this.federatedInstanceService.registerOrFetchInstanceDoc(host).then(i => { this.instancesRepository.update(i.id, { - latestRequestSentAt: new Date(), latestStatus: 200, lastCommunicatedAt: new Date(), isNotResponding: false, @@ -100,10 +99,9 @@ export class DeliverProcessorService { return 'Success'; } catch (res) { - // Update stats + // Update stats this.federatedInstanceService.registerOrFetchInstanceDoc(host).then(i => { this.instancesRepository.update(i.id, { - latestRequestSentAt: new Date(), latestStatus: res instanceof StatusError ? res.statusCode : null, isNotResponding: true, }); @@ -114,17 +112,17 @@ export class DeliverProcessorService { }); if (res instanceof StatusError) { - // 4xx + // 4xx if (res.isClientError) { - // HTTPステータスコード4xxはクライアントエラーであり、それはつまり - // 何回再送しても成功することはないということなのでエラーにはしないでおく + // HTTPステータスコード4xxはクライアントエラーであり、それはつまり + // 何回再送しても成功することはないということなのでエラーにはしないでおく return `${res.statusCode} ${res.statusMessage}`; } // 5xx etc. throw `${res.statusCode} ${res.statusMessage}`; } else { - // DNS error, socket error, timeout ... + // DNS error, socket error, timeout ... throw res; } } diff --git a/packages/frontend/src/pages/instance-info.vue b/packages/frontend/src/pages/instance-info.vue index f750fdcee2..23705cb22d 100644 --- a/packages/frontend/src/pages/instance-info.vue +++ b/packages/frontend/src/pages/instance-info.vue @@ -40,10 +40,6 @@ - - - - From c8bd13971355e1f2a720bdd7d5c75404833bc0bd Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 3 Jan 2023 09:00:42 +0900 Subject: [PATCH 04/24] drop lastCommunicatedAt of instance --- .../1672704017999-remove-lastCommunicatedAt.js | 11 +++++++++++ packages/backend/src/core/FederatedInstanceService.ts | 1 - packages/backend/src/core/chart/charts/federation.ts | 4 ++-- .../src/core/entities/InstanceEntityService.ts | 1 - packages/backend/src/models/entities/Instance.ts | 6 ------ .../backend/src/models/schema/federation-instance.ts | 5 ----- .../src/queue/processors/DeliverProcessorService.ts | 1 - .../src/queue/processors/InboxProcessorService.ts | 1 - .../src/server/api/endpoints/federation/instances.ts | 2 -- packages/frontend/src/pages/about.federation.vue | 4 +--- .../frontend/src/pages/admin/overview.instances.vue | 2 +- packages/frontend/src/pages/admin/overview.vue | 2 +- .../frontend/src/ui/_common_/statusbar-federation.vue | 2 +- packages/frontend/src/widgets/federation.vue | 2 +- packages/frontend/src/widgets/instance-cloud.vue | 2 +- 15 files changed, 19 insertions(+), 27 deletions(-) create mode 100644 packages/backend/migration/1672704017999-remove-lastCommunicatedAt.js diff --git a/packages/backend/migration/1672704017999-remove-lastCommunicatedAt.js b/packages/backend/migration/1672704017999-remove-lastCommunicatedAt.js new file mode 100644 index 0000000000..38a6769851 --- /dev/null +++ b/packages/backend/migration/1672704017999-remove-lastCommunicatedAt.js @@ -0,0 +1,11 @@ +export class removeLastCommunicatedAt1672704017999 { + name = 'removeLastCommunicatedAt1672704017999' + + async up(queryRunner) { + await queryRunner.query(`ALTER TABLE "instance" DROP COLUMN "lastCommunicatedAt"`); + } + + async down(queryRunner) { + await queryRunner.query(`ALTER TABLE "instance" ADD "lastCommunicatedAt" TIMESTAMP WITH TIME ZONE NOT NULL`); + } +} diff --git a/packages/backend/src/core/FederatedInstanceService.ts b/packages/backend/src/core/FederatedInstanceService.ts index 97745a1168..48e77caaee 100644 --- a/packages/backend/src/core/FederatedInstanceService.ts +++ b/packages/backend/src/core/FederatedInstanceService.ts @@ -35,7 +35,6 @@ export class FederatedInstanceService { id: this.idService.genId(), host, caughtAt: new Date(), - lastCommunicatedAt: new Date(), }).then(x => this.instancesRepository.findOneByOrFail(x.identifiers[0])); this.cache.set(host, i); diff --git a/packages/backend/src/core/chart/charts/federation.ts b/packages/backend/src/core/chart/charts/federation.ts index d9234e8028..b8012809f7 100644 --- a/packages/backend/src/core/chart/charts/federation.ts +++ b/packages/backend/src/core/chart/charts/federation.ts @@ -86,7 +86,7 @@ export default class FederationChart extends Chart { .where(`instance.host IN (${ subInstancesQuery.getQuery() })`) .andWhere(meta.blockedHosts.length === 0 ? '1=1' : 'instance.host NOT IN (:...blocked)', { blocked: meta.blockedHosts }) .andWhere('instance.isSuspended = false') - .andWhere('instance.lastCommunicatedAt > :gt', { gt: new Date(Date.now() - (1000 * 60 * 60 * 24 * 30)) }) + .andWhere('instance.isNotResponding = false') .getRawOne() .then(x => parseInt(x.count, 10)), this.instancesRepository.createQueryBuilder('instance') @@ -94,7 +94,7 @@ export default class FederationChart extends Chart { .where(`instance.host IN (${ pubInstancesQuery.getQuery() })`) .andWhere(meta.blockedHosts.length === 0 ? '1=1' : 'instance.host NOT IN (:...blocked)', { blocked: meta.blockedHosts }) .andWhere('instance.isSuspended = false') - .andWhere('instance.lastCommunicatedAt > :gt', { gt: new Date(Date.now() - (1000 * 60 * 60 * 24 * 30)) }) + .andWhere('instance.isNotResponding = false') .getRawOne() .then(x => parseInt(x.count, 10)), ]); diff --git a/packages/backend/src/core/entities/InstanceEntityService.ts b/packages/backend/src/core/entities/InstanceEntityService.ts index 7742608b07..81d02bb331 100644 --- a/packages/backend/src/core/entities/InstanceEntityService.ts +++ b/packages/backend/src/core/entities/InstanceEntityService.ts @@ -33,7 +33,6 @@ export class InstanceEntityService { notesCount: instance.notesCount, followingCount: instance.followingCount, followersCount: instance.followersCount, - lastCommunicatedAt: instance.lastCommunicatedAt.toISOString(), isNotResponding: instance.isNotResponding, isSuspended: instance.isSuspended, isBlocked: meta.blockedHosts.includes(instance.host), diff --git a/packages/backend/src/models/entities/Instance.ts b/packages/backend/src/models/entities/Instance.ts index e4e9835ce8..40d964dece 100644 --- a/packages/backend/src/models/entities/Instance.ts +++ b/packages/backend/src/models/entities/Instance.ts @@ -75,12 +75,6 @@ export class Instance { }) public latestRequestReceivedAt: Date | null; - /** - * このインスタンスと最後にやり取りした日時 - */ - @Column('timestamp with time zone') - public lastCommunicatedAt: Date; - /** * このインスタンスと不通かどうか */ diff --git a/packages/backend/src/models/schema/federation-instance.ts b/packages/backend/src/models/schema/federation-instance.ts index 739548103a..f3f93f3097 100644 --- a/packages/backend/src/models/schema/federation-instance.ts +++ b/packages/backend/src/models/schema/federation-instance.ts @@ -32,11 +32,6 @@ export const packedFederationInstanceSchema = { type: 'number', optional: false, nullable: false, }, - lastCommunicatedAt: { - type: 'string', - optional: false, nullable: false, - format: 'date-time', - }, isNotResponding: { type: 'boolean', optional: false, nullable: false, diff --git a/packages/backend/src/queue/processors/DeliverProcessorService.ts b/packages/backend/src/queue/processors/DeliverProcessorService.ts index 0e74260386..571b9e9045 100644 --- a/packages/backend/src/queue/processors/DeliverProcessorService.ts +++ b/packages/backend/src/queue/processors/DeliverProcessorService.ts @@ -86,7 +86,6 @@ export class DeliverProcessorService { this.federatedInstanceService.registerOrFetchInstanceDoc(host).then(i => { this.instancesRepository.update(i.id, { latestStatus: 200, - lastCommunicatedAt: new Date(), isNotResponding: false, }); diff --git a/packages/backend/src/queue/processors/InboxProcessorService.ts b/packages/backend/src/queue/processors/InboxProcessorService.ts index c032122caf..56058638c9 100644 --- a/packages/backend/src/queue/processors/InboxProcessorService.ts +++ b/packages/backend/src/queue/processors/InboxProcessorService.ts @@ -179,7 +179,6 @@ export class InboxProcessorService { this.federatedInstanceService.registerOrFetchInstanceDoc(authUser.user.host).then(i => { this.instancesRepository.update(i.id, { latestRequestReceivedAt: new Date(), - lastCommunicatedAt: new Date(), isNotResponding: false, }); diff --git a/packages/backend/src/server/api/endpoints/federation/instances.ts b/packages/backend/src/server/api/endpoints/federation/instances.ts index 81276a7ab0..6672434fb5 100644 --- a/packages/backend/src/server/api/endpoints/federation/instances.ts +++ b/packages/backend/src/server/api/endpoints/federation/instances.ts @@ -64,8 +64,6 @@ export default class extends Endpoint { case '-followers': query.orderBy('instance.followersCount', 'ASC'); break; case '+caughtAt': query.orderBy('instance.caughtAt', 'DESC'); break; case '-caughtAt': query.orderBy('instance.caughtAt', 'ASC'); break; - case '+lastCommunicatedAt': query.orderBy('instance.lastCommunicatedAt', 'DESC'); break; - case '-lastCommunicatedAt': query.orderBy('instance.lastCommunicatedAt', 'ASC'); break; default: query.orderBy('instance.id', 'DESC'); break; } diff --git a/packages/frontend/src/pages/about.federation.vue b/packages/frontend/src/pages/about.federation.vue index 2b20f383d1..1709f06a16 100644 --- a/packages/frontend/src/pages/about.federation.vue +++ b/packages/frontend/src/pages/about.federation.vue @@ -30,15 +30,13 @@ - -
- +
diff --git a/packages/frontend/src/pages/admin/overview.instances.vue b/packages/frontend/src/pages/admin/overview.instances.vue index ae10017aa8..15dbdc4639 100644 --- a/packages/frontend/src/pages/admin/overview.instances.vue +++ b/packages/frontend/src/pages/admin/overview.instances.vue @@ -22,7 +22,7 @@ const fetching = ref(true); const fetch = async () => { const fetchedInstances = await os.api('federation/instances', { - sort: '+lastCommunicatedAt', + sort: '+latestRequestReceivedAt', limit: 6, }); instances.value = fetchedInstances; diff --git a/packages/frontend/src/pages/admin/overview.vue b/packages/frontend/src/pages/admin/overview.vue index d656e55200..5fdfa5f263 100644 --- a/packages/frontend/src/pages/admin/overview.vue +++ b/packages/frontend/src/pages/admin/overview.vue @@ -153,7 +153,7 @@ onMounted(async () => { }); os.api('federation/instances', { - sort: '+lastCommunicatedAt', + sort: '+latestRequestReceivedAt', limit: 25, }).then(res => { activeInstances = res; diff --git a/packages/frontend/src/ui/_common_/statusbar-federation.vue b/packages/frontend/src/ui/_common_/statusbar-federation.vue index 7c3de32ac9..70d683d755 100644 --- a/packages/frontend/src/ui/_common_/statusbar-federation.vue +++ b/packages/frontend/src/ui/_common_/statusbar-federation.vue @@ -44,7 +44,7 @@ let key = $ref(0); const tick = () => { os.api('federation/instances', { - sort: '+lastCommunicatedAt', + sort: '+latestRequestReceivedAt', limit: 30, }).then(res => { instances.value = res; diff --git a/packages/frontend/src/widgets/federation.vue b/packages/frontend/src/widgets/federation.vue index 221972bc6f..a701ca5673 100644 --- a/packages/frontend/src/widgets/federation.vue +++ b/packages/frontend/src/widgets/federation.vue @@ -58,7 +58,7 @@ const fetching = ref(true); const fetch = async () => { const fetchedInstances = await os.api('federation/instances', { - sort: '+lastCommunicatedAt', + sort: '+latestRequestReceivedAt', limit: 5, }); const fetchedCharts = await Promise.all(fetchedInstances.map(i => os.apiGet('charts/instance', { host: i.host, limit: 16, span: 'hour' }))); diff --git a/packages/frontend/src/widgets/instance-cloud.vue b/packages/frontend/src/widgets/instance-cloud.vue index 4965616995..6d522ddbe8 100644 --- a/packages/frontend/src/widgets/instance-cloud.vue +++ b/packages/frontend/src/widgets/instance-cloud.vue @@ -54,7 +54,7 @@ function onInstanceClick(i) { useInterval(() => { os.api('federation/instances', { - sort: '+lastCommunicatedAt', + sort: '+latestRequestReceivedAt', limit: 25, }).then(res => { activeInstances = res; From 4d0859ce7f33a02bc7242c8a9f22ce253ff9f7c0 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 3 Jan 2023 09:03:04 +0900 Subject: [PATCH 05/24] drop latestStatus of instance --- .../migration/1672704136584-remove-latestStatus.js | 11 +++++++++++ packages/backend/src/models/entities/Instance.ts | 8 -------- .../src/queue/processors/DeliverProcessorService.ts | 2 -- packages/frontend/src/pages/instance-info.vue | 4 ---- 4 files changed, 11 insertions(+), 14 deletions(-) create mode 100644 packages/backend/migration/1672704136584-remove-latestStatus.js diff --git a/packages/backend/migration/1672704136584-remove-latestStatus.js b/packages/backend/migration/1672704136584-remove-latestStatus.js new file mode 100644 index 0000000000..937c2fe8fd --- /dev/null +++ b/packages/backend/migration/1672704136584-remove-latestStatus.js @@ -0,0 +1,11 @@ +export class removeLatestStatus1672704136584 { + name = 'removeLatestStatus1672704136584' + + async up(queryRunner) { + await queryRunner.query(`ALTER TABLE "instance" DROP COLUMN "latestStatus"`); + } + + async down(queryRunner) { + await queryRunner.query(`ALTER TABLE "instance" ADD "latestStatus" integer`); + } +} diff --git a/packages/backend/src/models/entities/Instance.ts b/packages/backend/src/models/entities/Instance.ts index 40d964dece..8092f67c86 100644 --- a/packages/backend/src/models/entities/Instance.ts +++ b/packages/backend/src/models/entities/Instance.ts @@ -59,14 +59,6 @@ export class Instance { }) public followersCount: number; - /** - * 直近のリクエスト送信時のHTTPステータスコード - */ - @Column('integer', { - nullable: true, - }) - public latestStatus: number | null; - /** * 直近のリクエスト受信日時 */ diff --git a/packages/backend/src/queue/processors/DeliverProcessorService.ts b/packages/backend/src/queue/processors/DeliverProcessorService.ts index 571b9e9045..fcff3a0e2a 100644 --- a/packages/backend/src/queue/processors/DeliverProcessorService.ts +++ b/packages/backend/src/queue/processors/DeliverProcessorService.ts @@ -85,7 +85,6 @@ export class DeliverProcessorService { // Update stats this.federatedInstanceService.registerOrFetchInstanceDoc(host).then(i => { this.instancesRepository.update(i.id, { - latestStatus: 200, isNotResponding: false, }); @@ -101,7 +100,6 @@ export class DeliverProcessorService { // Update stats this.federatedInstanceService.registerOrFetchInstanceDoc(host).then(i => { this.instancesRepository.update(i.id, { - latestStatus: res instanceof StatusError ? res.statusCode : null, isNotResponding: true, }); diff --git a/packages/frontend/src/pages/instance-info.vue b/packages/frontend/src/pages/instance-info.vue index 23705cb22d..55771b0e30 100644 --- a/packages/frontend/src/pages/instance-info.vue +++ b/packages/frontend/src/pages/instance-info.vue @@ -40,10 +40,6 @@
- - - - From 631ffc8cf6efce264c84f08f2b1c54403a360942 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 3 Jan 2023 09:19:54 +0900 Subject: [PATCH 06/24] fix style --- packages/frontend/src/pages/admin/index.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/frontend/src/pages/admin/index.vue b/packages/frontend/src/pages/admin/index.vue index 406677229f..c71ebd4e2e 100644 --- a/packages/frontend/src/pages/admin/index.vue +++ b/packages/frontend/src/pages/admin/index.vue @@ -16,7 +16,7 @@ -
+
From 4cc71d24439375488655904048a3651455e44ad3 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 3 Jan 2023 09:32:36 +0900 Subject: [PATCH 07/24] :v: --- .../src/core/FederatedInstanceService.ts | 15 ++++++++++- .../backend/src/core/NoteCreateService.ts | 2 +- .../backend/src/core/NoteDeleteService.ts | 2 +- .../backend/src/core/UserFollowingService.ts | 8 +++--- .../activitypub/models/ApPersonService.ts | 2 +- .../processors/DeliverProcessorService.ts | 26 +++++++++++++------ .../queue/processors/InboxProcessorService.ts | 5 +++- .../api/endpoints/federation/instances.ts | 2 ++ 8 files changed, 45 insertions(+), 17 deletions(-) diff --git a/packages/backend/src/core/FederatedInstanceService.ts b/packages/backend/src/core/FederatedInstanceService.ts index 48e77caaee..d517117da6 100644 --- a/packages/backend/src/core/FederatedInstanceService.ts +++ b/packages/backend/src/core/FederatedInstanceService.ts @@ -22,7 +22,7 @@ export class FederatedInstanceService { } @bindThis - public async registerOrFetchInstanceDoc(host: string): Promise { + public async fetch(host: string): Promise { host = this.utilityService.toPuny(host); const cached = this.cache.get(host); @@ -44,4 +44,17 @@ export class FederatedInstanceService { return index; } } + + @bindThis + public async updateCachePartial(host: string, data: Partial): Promise { + host = this.utilityService.toPuny(host); + + const cached = this.cache.get(host); + if (cached == null) return; + + this.cache.set(host, { + ...cached, + ...data, + }); + } } diff --git a/packages/backend/src/core/NoteCreateService.ts b/packages/backend/src/core/NoteCreateService.ts index cc6c213446..6038840406 100644 --- a/packages/backend/src/core/NoteCreateService.ts +++ b/packages/backend/src/core/NoteCreateService.ts @@ -428,7 +428,7 @@ export class NoteCreateService { // Register host if (this.userEntityService.isRemoteUser(user)) { - this.federatedInstanceService.registerOrFetchInstanceDoc(user.host).then(i => { + this.federatedInstanceService.fetch(user.host).then(i => { this.instancesRepository.increment({ id: i.id }, 'notesCount', 1); this.instanceChart.updateNote(i.host, note, true); }); diff --git a/packages/backend/src/core/NoteDeleteService.ts b/packages/backend/src/core/NoteDeleteService.ts index 1313fcbd3d..b1f16b6e8a 100644 --- a/packages/backend/src/core/NoteDeleteService.ts +++ b/packages/backend/src/core/NoteDeleteService.ts @@ -100,7 +100,7 @@ export class NoteDeleteService { this.perUserNotesChart.update(user, note, false); if (this.userEntityService.isRemoteUser(user)) { - this.federatedInstanceService.registerOrFetchInstanceDoc(user.host).then(i => { + this.federatedInstanceService.fetch(user.host).then(i => { this.instancesRepository.decrement({ id: i.id }, 'notesCount', 1); this.instanceChart.updateNote(i.host, note, false); }); diff --git a/packages/backend/src/core/UserFollowingService.ts b/packages/backend/src/core/UserFollowingService.ts index 074aae86c8..52834c375e 100644 --- a/packages/backend/src/core/UserFollowingService.ts +++ b/packages/backend/src/core/UserFollowingService.ts @@ -205,12 +205,12 @@ export class UserFollowingService { //#region Update instance stats if (this.userEntityService.isRemoteUser(follower) && this.userEntityService.isLocalUser(followee)) { - this.federatedInstanceService.registerOrFetchInstanceDoc(follower.host).then(i => { + this.federatedInstanceService.fetch(follower.host).then(i => { this.instancesRepository.increment({ id: i.id }, 'followingCount', 1); this.instanceChart.updateFollowing(i.host, true); }); } else if (this.userEntityService.isLocalUser(follower) && this.userEntityService.isRemoteUser(followee)) { - this.federatedInstanceService.registerOrFetchInstanceDoc(followee.host).then(i => { + this.federatedInstanceService.fetch(followee.host).then(i => { this.instancesRepository.increment({ id: i.id }, 'followersCount', 1); this.instanceChart.updateFollowers(i.host, true); }); @@ -323,12 +323,12 @@ export class UserFollowingService { //#region Update instance stats if (this.userEntityService.isRemoteUser(follower) && this.userEntityService.isLocalUser(followee)) { - this.federatedInstanceService.registerOrFetchInstanceDoc(follower.host).then(i => { + this.federatedInstanceService.fetch(follower.host).then(i => { this.instancesRepository.decrement({ id: i.id }, 'followingCount', 1); this.instanceChart.updateFollowing(i.host, false); }); } else if (this.userEntityService.isLocalUser(follower) && this.userEntityService.isRemoteUser(followee)) { - this.federatedInstanceService.registerOrFetchInstanceDoc(followee.host).then(i => { + this.federatedInstanceService.fetch(followee.host).then(i => { this.instancesRepository.decrement({ id: i.id }, 'followersCount', 1); this.instanceChart.updateFollowers(i.host, false); }); diff --git a/packages/backend/src/core/activitypub/models/ApPersonService.ts b/packages/backend/src/core/activitypub/models/ApPersonService.ts index d5faf37df2..e08f33c906 100644 --- a/packages/backend/src/core/activitypub/models/ApPersonService.ts +++ b/packages/backend/src/core/activitypub/models/ApPersonService.ts @@ -348,7 +348,7 @@ export class ApPersonService implements OnModuleInit { } // Register host - this.federatedInstanceService.registerOrFetchInstanceDoc(host).then(i => { + this.federatedInstanceService.fetch(host).then(i => { this.instancesRepository.increment({ id: i.id }, 'usersCount', 1); this.instanceChart.newUser(i.host); this.fetchInstanceMetadataService.fetchInstanceMetadata(i); diff --git a/packages/backend/src/queue/processors/DeliverProcessorService.ts b/packages/backend/src/queue/processors/DeliverProcessorService.ts index fcff3a0e2a..d62e1f643a 100644 --- a/packages/backend/src/queue/processors/DeliverProcessorService.ts +++ b/packages/backend/src/queue/processors/DeliverProcessorService.ts @@ -83,10 +83,15 @@ export class DeliverProcessorService { await this.apRequestService.signedPost(job.data.user, job.data.to, job.data.content); // Update stats - this.federatedInstanceService.registerOrFetchInstanceDoc(host).then(i => { - this.instancesRepository.update(i.id, { - isNotResponding: false, - }); + this.federatedInstanceService.fetch(host).then(i => { + if (i.isNotResponding) { + this.instancesRepository.update(i.id, { + isNotResponding: false, + }); + this.federatedInstanceService.updateCachePartial(host, { + isNotResponding: false, + }); + } this.fetchInstanceMetadataService.fetchInstanceMetadata(i); @@ -98,10 +103,15 @@ export class DeliverProcessorService { return 'Success'; } catch (res) { // Update stats - this.federatedInstanceService.registerOrFetchInstanceDoc(host).then(i => { - this.instancesRepository.update(i.id, { - isNotResponding: true, - }); + this.federatedInstanceService.fetch(host).then(i => { + if (!i.isNotResponding) { + this.instancesRepository.update(i.id, { + isNotResponding: true, + }); + this.federatedInstanceService.updateCachePartial(host, { + isNotResponding: true, + }); + } this.instanceChart.requestSent(i.host, false); this.apRequestChart.deliverFail(); diff --git a/packages/backend/src/queue/processors/InboxProcessorService.ts b/packages/backend/src/queue/processors/InboxProcessorService.ts index 56058638c9..d033637849 100644 --- a/packages/backend/src/queue/processors/InboxProcessorService.ts +++ b/packages/backend/src/queue/processors/InboxProcessorService.ts @@ -176,11 +176,14 @@ export class InboxProcessorService { } // Update stats - this.federatedInstanceService.registerOrFetchInstanceDoc(authUser.user.host).then(i => { + this.federatedInstanceService.fetch(authUser.user.host).then(i => { this.instancesRepository.update(i.id, { latestRequestReceivedAt: new Date(), isNotResponding: false, }); + this.federatedInstanceService.updateCachePartial(host, { + isNotResponding: false, + }); this.fetchInstanceMetadataService.fetchInstanceMetadata(i); diff --git a/packages/backend/src/server/api/endpoints/federation/instances.ts b/packages/backend/src/server/api/endpoints/federation/instances.ts index 6672434fb5..180887285a 100644 --- a/packages/backend/src/server/api/endpoints/federation/instances.ts +++ b/packages/backend/src/server/api/endpoints/federation/instances.ts @@ -64,6 +64,8 @@ export default class extends Endpoint { case '-followers': query.orderBy('instance.followersCount', 'ASC'); break; case '+caughtAt': query.orderBy('instance.caughtAt', 'DESC'); break; case '-caughtAt': query.orderBy('instance.caughtAt', 'ASC'); break; + case '+latestRequestReceivedAt': query.orderBy('instance.latestRequestReceivedAt', 'DESC'); break; + case '-latestRequestReceivedAt': query.orderBy('instance.latestRequestReceivedAt', 'ASC'); break; default: query.orderBy('instance.id', 'DESC'); break; } From 06a37674094e3a095165d2a5015f5454d889e64b Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 3 Jan 2023 09:38:18 +0900 Subject: [PATCH 08/24] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 656f69643c..3b39c66042 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,7 @@ You should also include the user name that made the change. - Server: delete outdated notifications regularly to improve db performance @syuilo - Server: delete outdated hard-mutes regularly to improve db performance @syuilo - Server: delete outdated notes of antenna regularly to improve db performance @syuilo +- Server: improve activitypub deliver performance @syuilo - Client: use tabler-icons instead of fontawesome to better design @syuilo - Client: Add new gabber kick sounds (thanks for noizenecio) - Client: Add link to user RSS feed in profile menu @ssmucny From a0af80f8c5bf91a393f2e3728dc4a85f9721f0bd Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 3 Jan 2023 09:41:32 +0900 Subject: [PATCH 09/24] tweak displayLimit of pagination --- packages/frontend/src/components/MkPagination.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/frontend/src/components/MkPagination.vue b/packages/frontend/src/components/MkPagination.vue index dc2a9832fe..b5a6bd271a 100644 --- a/packages/frontend/src/components/MkPagination.vue +++ b/packages/frontend/src/components/MkPagination.vue @@ -65,7 +65,7 @@ const props = withDefaults(defineProps<{ disableAutoLoad?: boolean; displayLimit?: number; }>(), { - displayLimit: 30, + displayLimit: 20, }); const emit = defineEmits<{ From 2184240ef146742a61ee12d5536922278b486d29 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 3 Jan 2023 10:12:37 +0900 Subject: [PATCH 10/24] perf(client): use shallowRef for html element ref --- packages/frontend/src/components/MkAutocomplete.vue | 10 +++++----- packages/frontend/src/components/MkButton.vue | 4 ++-- packages/frontend/src/components/MkCaptcha.vue | 6 +++--- packages/frontend/src/components/MkChart.vue | 4 ++-- packages/frontend/src/components/MkContextMenu.vue | 2 +- packages/frontend/src/components/MkCropperDialog.vue | 2 +- packages/frontend/src/components/MkDrive.vue | 4 ++-- packages/frontend/src/components/MkEmojiPicker.vue | 6 +++--- packages/frontend/src/components/MkHeatmap.vue | 4 ++-- packages/frontend/src/components/MkImgWithBlurhash.vue | 2 +- packages/frontend/src/components/MkInstanceStats.vue | 4 ++-- packages/frontend/src/components/MkMediaBanner.vue | 2 +- packages/frontend/src/components/MkMenu.child.vue | 4 ++-- packages/frontend/src/components/MkMenu.vue | 4 ++-- packages/frontend/src/components/MkModal.vue | 2 +- packages/frontend/src/components/MkModalWindow.vue | 4 ++-- packages/frontend/src/components/MkNote.vue | 10 +++++----- packages/frontend/src/components/MkNoteDetailed.vue | 10 +++++----- packages/frontend/src/components/MkNotification.vue | 4 ++-- packages/frontend/src/components/MkPagination.vue | 4 ++-- packages/frontend/src/components/MkPostForm.vue | 8 ++++---- .../src/components/MkReactionsViewer.reaction.vue | 4 ++-- packages/frontend/src/components/MkRenoteButton.vue | 4 ++-- .../frontend/src/components/MkRetentionHeatmap.vue | 4 ++-- packages/frontend/src/components/MkSparkle.vue | 4 ++-- packages/frontend/src/components/MkTagCloud.vue | 6 +++--- packages/frontend/src/components/MkTooltip.vue | 4 ++-- packages/frontend/src/components/MkVisibility.vue | 2 +- packages/frontend/src/components/MkWindow.vue | 2 +- packages/frontend/src/components/form/checkbox.vue | 2 +- packages/frontend/src/components/form/folder.vue | 2 +- packages/frontend/src/components/form/input.vue | 8 ++++---- packages/frontend/src/components/form/switch.vue | 2 +- .../frontend/src/components/global/MkPageHeader.vue | 4 ++-- packages/frontend/src/components/global/MkSpacer.vue | 5 ++--- .../src/components/global/MkStickyContainer.vue | 6 +++--- packages/frontend/src/pages/about-misskey.vue | 2 +- packages/frontend/src/pages/admin/_header_.vue | 6 +++--- .../frontend/src/pages/admin/overview.active-users.vue | 2 +- .../frontend/src/pages/admin/overview.ap-requests.vue | 4 ++-- packages/frontend/src/pages/admin/overview.pie.vue | 4 ++-- .../frontend/src/pages/admin/overview.queue.chart.vue | 4 ++-- packages/frontend/src/pages/admin/overview.vue | 2 +- .../frontend/src/pages/admin/queue.chart.chart.vue | 4 ++-- packages/frontend/src/pages/antenna-timeline.vue | 2 +- .../src/pages/messaging/messaging-room.form.vue | 4 ++-- .../frontend/src/pages/messaging/messaging-room.vue | 2 +- packages/frontend/src/pages/settings/index.vue | 4 ++-- packages/frontend/src/pages/timeline.vue | 2 +- packages/frontend/src/pages/user-list-timeline.vue | 2 +- packages/frontend/src/pages/user/activity.heatmap.vue | 4 ++-- packages/frontend/src/pages/user/activity.pv.vue | 2 +- packages/frontend/src/ui/classic.vue | 2 +- packages/frontend/src/ui/deck.vue | 2 +- packages/frontend/src/ui/deck/column.vue | 2 +- packages/frontend/src/ui/universal.vue | 2 +- packages/frontend/src/ui/universal.widgets.vue | 2 +- packages/frontend/src/widgets/aichan.vue | 4 ++-- packages/frontend/src/widgets/slideshow.vue | 6 +++--- 59 files changed, 114 insertions(+), 115 deletions(-) diff --git a/packages/frontend/src/components/MkAutocomplete.vue b/packages/frontend/src/components/MkAutocomplete.vue index a2b020b900..08e2c29de2 100644 --- a/packages/frontend/src/components/MkAutocomplete.vue +++ b/packages/frontend/src/components/MkAutocomplete.vue @@ -16,9 +16,9 @@
    -
  1. +
  2. - +
    @@ -35,7 +35,8 @@ diff --git a/packages/frontend/src/ui/classic.vue b/packages/frontend/src/ui/classic.vue index ba9120a77d..280e69e7dd 100644 --- a/packages/frontend/src/ui/classic.vue +++ b/packages/frontend/src/ui/classic.vue @@ -76,7 +76,7 @@ provideMetadataReceiver((info) => { } }); provide('shouldHeaderThin', showMenuOnTop); -provide('shouldSpacerMin', true); +provide('forceSpacerMin', true); function attachSticky(el) { const sticky = new StickySidebar(el, defaultStore.state.menuDisplay === 'top' ? 0 : 16, defaultStore.state.menuDisplay === 'top' ? 60 : 0); // TODO: ヘッダーの高さを60pxと決め打ちしているのを直す diff --git a/packages/frontend/src/ui/deck/column.vue b/packages/frontend/src/ui/deck/column.vue index 0b8d6afe55..775bdf6c1e 100644 --- a/packages/frontend/src/ui/deck/column.vue +++ b/packages/frontend/src/ui/deck/column.vue @@ -40,7 +40,7 @@ import { MenuItem } from '@/types/menu'; provide('shouldHeaderThin', true); provide('shouldOmitHeaderTitle', true); -provide('shouldSpacerMin', true); +provide('forceSpacerMin', true); const props = withDefaults(defineProps<{ column: Column; From aca445c7c824def25437e7d3d9c75adb60c30280 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 3 Jan 2023 10:53:20 +0900 Subject: [PATCH 12/24] 13.0.0-beta.18 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0ae0bb2a32..ec1fa7ef43 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "misskey", - "version": "13.0.0-beta.17", + "version": "13.0.0-beta.18", "codename": "indigo", "repository": { "type": "git", From aa0eaf37b6e54719616548a971169ce8a6a2c17c Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 3 Jan 2023 10:57:52 +0900 Subject: [PATCH 13/24] :art: --- packages/frontend/src/components/MkMenu.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/frontend/src/components/MkMenu.vue b/packages/frontend/src/components/MkMenu.vue index b893e80345..0db0767fac 100644 --- a/packages/frontend/src/components/MkMenu.vue +++ b/packages/frontend/src/components/MkMenu.vue @@ -203,7 +203,7 @@ onBeforeUnmount(() => { > .item { display: block; position: relative; - padding: 6px 16px; + padding: 5px 16px; width: 100%; box-sizing: border-box; white-space: nowrap; From 459151c1f210ba0df5ea0cd56d33f8551b75d91d Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 3 Jan 2023 13:04:58 +0900 Subject: [PATCH 14/24] clean up --- packages/frontend/src/pages/admin/metrics.vue | 439 ------------------ 1 file changed, 439 deletions(-) delete mode 100644 packages/frontend/src/pages/admin/metrics.vue diff --git a/packages/frontend/src/pages/admin/metrics.vue b/packages/frontend/src/pages/admin/metrics.vue deleted file mode 100644 index f32b52d30a..0000000000 --- a/packages/frontend/src/pages/admin/metrics.vue +++ /dev/null @@ -1,439 +0,0 @@ - - - - - From 826e4502cb45441614e4881fab9307f85f4fd069 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 3 Jan 2023 13:09:24 +0900 Subject: [PATCH 15/24] refactor --- packages/frontend/src/components/MkChart.vue | 1 - packages/frontend/src/components/MkHeatmap.vue | 3 +-- packages/frontend/src/components/MkRetentionHeatmap.vue | 3 +-- packages/frontend/src/pages/admin/overview.active-users.vue | 3 +-- packages/frontend/src/pages/admin/overview.vue | 1 - packages/frontend/src/pages/user/activity.heatmap.vue | 1 - packages/frontend/src/pages/user/activity.pv.vue | 3 +-- packages/frontend/src/scripts/init-chart.ts | 1 + 8 files changed, 5 insertions(+), 11 deletions(-) diff --git a/packages/frontend/src/components/MkChart.vue b/packages/frontend/src/components/MkChart.vue index 7d3a3d289b..c0562f02e3 100644 --- a/packages/frontend/src/components/MkChart.vue +++ b/packages/frontend/src/components/MkChart.vue @@ -15,7 +15,6 @@ */ import { onMounted, ref, shallowRef, watch, PropType, onUnmounted } from 'vue'; import { Chart } from 'chart.js'; -import 'chartjs-adapter-date-fns'; import { enUS } from 'date-fns/locale'; import gradient from 'chartjs-plugin-gradient'; import * as os from '@/os'; diff --git a/packages/frontend/src/components/MkHeatmap.vue b/packages/frontend/src/components/MkHeatmap.vue index fff93ef965..ec7f49beee 100644 --- a/packages/frontend/src/components/MkHeatmap.vue +++ b/packages/frontend/src/components/MkHeatmap.vue @@ -12,11 +12,10 @@ import { markRaw, version as vueVersion, onMounted, onBeforeUnmount, nextTick, w import { Chart } from 'chart.js'; import { enUS } from 'date-fns/locale'; import tinycolor from 'tinycolor2'; +import { MatrixController, MatrixElement } from 'chartjs-chart-matrix'; import * as os from '@/os'; -import 'chartjs-adapter-date-fns'; import { defaultStore } from '@/store'; import { useChartTooltip } from '@/scripts/use-chart-tooltip'; -import { MatrixController, MatrixElement } from 'chartjs-chart-matrix'; import { chartVLine } from '@/scripts/chart-vline'; import { alpha } from '@/scripts/color'; import { initChart } from '@/scripts/init-chart'; diff --git a/packages/frontend/src/components/MkRetentionHeatmap.vue b/packages/frontend/src/components/MkRetentionHeatmap.vue index 95690bde47..e91b58a4a8 100644 --- a/packages/frontend/src/components/MkRetentionHeatmap.vue +++ b/packages/frontend/src/components/MkRetentionHeatmap.vue @@ -12,11 +12,10 @@ import { markRaw, version as vueVersion, onMounted, onBeforeUnmount, nextTick } import { Chart } from 'chart.js'; import { enUS } from 'date-fns/locale'; import tinycolor from 'tinycolor2'; +import { MatrixController, MatrixElement } from 'chartjs-chart-matrix'; import * as os from '@/os'; -import 'chartjs-adapter-date-fns'; import { defaultStore } from '@/store'; import { useChartTooltip } from '@/scripts/use-chart-tooltip'; -import { MatrixController, MatrixElement } from 'chartjs-chart-matrix'; import { chartVLine } from '@/scripts/chart-vline'; import { alpha } from '@/scripts/color'; import { initChart } from '@/scripts/init-chart'; diff --git a/packages/frontend/src/pages/admin/overview.active-users.vue b/packages/frontend/src/pages/admin/overview.active-users.vue index e01009b7aa..14b09f34e9 100644 --- a/packages/frontend/src/pages/admin/overview.active-users.vue +++ b/packages/frontend/src/pages/admin/overview.active-users.vue @@ -12,11 +12,10 @@ import { markRaw, version as vueVersion, onMounted, onBeforeUnmount, nextTick } import { Chart } from 'chart.js'; import { enUS } from 'date-fns/locale'; import tinycolor from 'tinycolor2'; +import gradient from 'chartjs-plugin-gradient'; import * as os from '@/os'; -import 'chartjs-adapter-date-fns'; import { defaultStore } from '@/store'; import { useChartTooltip } from '@/scripts/use-chart-tooltip'; -import gradient from 'chartjs-plugin-gradient'; import { chartVLine } from '@/scripts/chart-vline'; import { alpha } from '@/scripts/color'; import { initChart } from '@/scripts/init-chart'; diff --git a/packages/frontend/src/pages/admin/overview.vue b/packages/frontend/src/pages/admin/overview.vue index c16a928a80..2e0b49c5a3 100644 --- a/packages/frontend/src/pages/admin/overview.vue +++ b/packages/frontend/src/pages/admin/overview.vue @@ -77,7 +77,6 @@ import * as os from '@/os'; import { stream } from '@/stream'; import { i18n } from '@/i18n'; import { definePageMetadata } from '@/scripts/page-metadata'; -import 'chartjs-adapter-date-fns'; import { defaultStore } from '@/store'; import MkFileListForAdmin from '@/components/MkFileListForAdmin.vue'; import MkFolder from '@/components/MkFolder.vue'; diff --git a/packages/frontend/src/pages/user/activity.heatmap.vue b/packages/frontend/src/pages/user/activity.heatmap.vue index 8472f79948..252985d113 100644 --- a/packages/frontend/src/pages/user/activity.heatmap.vue +++ b/packages/frontend/src/pages/user/activity.heatmap.vue @@ -14,7 +14,6 @@ import { enUS } from 'date-fns/locale'; import tinycolor from 'tinycolor2'; import * as misskey from 'misskey-js'; import * as os from '@/os'; -import 'chartjs-adapter-date-fns'; import { defaultStore } from '@/store'; import { useChartTooltip } from '@/scripts/use-chart-tooltip'; import { chartVLine } from '@/scripts/chart-vline'; diff --git a/packages/frontend/src/pages/user/activity.pv.vue b/packages/frontend/src/pages/user/activity.pv.vue index eaaeba976c..2d83d1ddc3 100644 --- a/packages/frontend/src/pages/user/activity.pv.vue +++ b/packages/frontend/src/pages/user/activity.pv.vue @@ -13,11 +13,10 @@ import { Chart } from 'chart.js'; import { enUS } from 'date-fns/locale'; import tinycolor from 'tinycolor2'; import * as misskey from 'misskey-js'; +import gradient from 'chartjs-plugin-gradient'; import * as os from '@/os'; -import 'chartjs-adapter-date-fns'; import { defaultStore } from '@/store'; import { useChartTooltip } from '@/scripts/use-chart-tooltip'; -import gradient from 'chartjs-plugin-gradient'; import { chartVLine } from '@/scripts/chart-vline'; import { alpha } from '@/scripts/color'; import { initChart } from '@/scripts/init-chart'; diff --git a/packages/frontend/src/scripts/init-chart.ts b/packages/frontend/src/scripts/init-chart.ts index 005ac5e271..fc18869009 100644 --- a/packages/frontend/src/scripts/init-chart.ts +++ b/packages/frontend/src/scripts/init-chart.ts @@ -20,6 +20,7 @@ import gradient from 'chartjs-plugin-gradient'; import zoomPlugin from 'chartjs-plugin-zoom'; import { MatrixController, MatrixElement } from 'chartjs-chart-matrix'; import { defaultStore } from '@/store'; +import 'chartjs-adapter-date-fns'; export function initChart() { Chart.register( From c93f091ba8c6f6d9ecf3c9a5c5a17bd532a58f54 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 3 Jan 2023 13:37:32 +0900 Subject: [PATCH 16/24] perf(client): use shallowRef instead of ref for template reference --- packages/frontend/src/components/MkAbuseReportWindow.vue | 4 ++-- packages/frontend/src/components/MkCropperDialog.vue | 2 +- packages/frontend/src/components/MkDialog.vue | 4 ++-- packages/frontend/src/components/MkDrive.vue | 2 +- packages/frontend/src/components/MkDriveSelectDialog.vue | 4 ++-- packages/frontend/src/components/MkEmojiPickerDialog.vue | 6 +++--- .../frontend/src/components/MkFileCaptionEditWindow.vue | 2 +- packages/frontend/src/components/MkImageViewer.vue | 2 +- packages/frontend/src/components/MkLaunchPad.vue | 2 +- packages/frontend/src/components/MkMenu.vue | 2 +- packages/frontend/src/components/MkModalPageWindow.vue | 2 +- packages/frontend/src/components/MkModalWindow.vue | 2 +- packages/frontend/src/components/MkNote.vue | 2 +- packages/frontend/src/components/MkNoteDetailed.vue | 2 +- packages/frontend/src/components/MkNotes.vue | 4 ++-- .../src/components/MkNotificationSettingWindow.vue | 2 +- packages/frontend/src/components/MkNotifications.vue | 4 ++-- packages/frontend/src/components/MkPageWindow.vue | 2 +- packages/frontend/src/components/MkPopupMenu.vue | 2 +- packages/frontend/src/components/MkPostFormDialog.vue | 4 ++-- packages/frontend/src/components/MkSigninDialog.vue | 2 +- packages/frontend/src/components/MkSignupDialog.vue | 2 +- .../frontend/src/components/MkTokenGenerateWindow.vue | 2 +- packages/frontend/src/components/MkUpdated.vue | 4 ++-- packages/frontend/src/components/MkUserList.vue | 6 ++---- packages/frontend/src/components/MkVisibilityPicker.vue | 2 +- packages/frontend/src/components/MkWaitingDialog.vue | 4 ++-- packages/frontend/src/pages/admin/abuses.vue | 2 +- packages/frontend/src/pages/admin/emojis.vue | 4 ++-- packages/frontend/src/pages/admin/overview.queue.vue | 8 ++++---- packages/frontend/src/pages/admin/queue.chart.vue | 8 ++++---- packages/frontend/src/pages/admin/users.vue | 2 +- packages/frontend/src/pages/antenna-timeline.vue | 2 +- packages/frontend/src/pages/explore.users.vue | 2 +- packages/frontend/src/pages/explore.vue | 2 +- packages/frontend/src/pages/favorites.vue | 4 +--- packages/frontend/src/pages/follow-requests.vue | 4 ++-- packages/frontend/src/pages/messaging/messaging-room.vue | 4 ++-- packages/frontend/src/pages/my-clips/index.vue | 2 +- packages/frontend/src/pages/my-lists/index.vue | 2 +- packages/frontend/src/pages/settings/notifications.vue | 2 +- packages/frontend/src/pages/timeline.vue | 2 +- packages/frontend/src/pages/user-list-timeline.vue | 2 +- packages/frontend/src/ui/deck/antenna-column.vue | 2 +- packages/frontend/src/ui/deck/list-column.vue | 2 +- packages/frontend/src/widgets/instance-cloud.vue | 2 +- 46 files changed, 66 insertions(+), 70 deletions(-) diff --git a/packages/frontend/src/components/MkAbuseReportWindow.vue b/packages/frontend/src/components/MkAbuseReportWindow.vue index 039f77c859..ab90ed357a 100644 --- a/packages/frontend/src/components/MkAbuseReportWindow.vue +++ b/packages/frontend/src/components/MkAbuseReportWindow.vue @@ -23,7 +23,7 @@ diff --git a/packages/frontend/src/pages/user/activity.pv.vue b/packages/frontend/src/pages/user/activity.pv.vue index 2d83d1ddc3..7715b66673 100644 --- a/packages/frontend/src/pages/user/activity.pv.vue +++ b/packages/frontend/src/pages/user/activity.pv.vue @@ -3,6 +3,7 @@
    +
    @@ -20,6 +21,8 @@ import { useChartTooltip } from '@/scripts/use-chart-tooltip'; import { chartVLine } from '@/scripts/chart-vline'; import { alpha } from '@/scripts/color'; import { initChart } from '@/scripts/init-chart'; +import { chartLegend } from '@/scripts/chart-legend'; +import MkChartLegend from '@/components/MkChartLegend.vue'; initChart(); @@ -28,6 +31,7 @@ const props = defineProps<{ }>(); const chartEl = $shallowRef(null); +let legendEl = $shallowRef>(); const now = new Date(); let chartInstance: Chart = null; const chartLimit = 30; @@ -153,14 +157,7 @@ async function renderChart() { }, }, legend: { - display: true, - position: 'bottom', - padding: { - left: 0, - right: 0, - top: 8, - bottom: 0, - }, + display: false, }, tooltip: { enabled: false, @@ -173,7 +170,7 @@ async function renderChart() { gradient, }, }, - plugins: [chartVLine(vLineColor)], + plugins: [chartVLine(vLineColor), chartLegend(legendEl)], }); fetching = false; diff --git a/packages/frontend/src/scripts/chart-legend.ts b/packages/frontend/src/scripts/chart-legend.ts new file mode 100644 index 0000000000..6a5370cc87 --- /dev/null +++ b/packages/frontend/src/scripts/chart-legend.ts @@ -0,0 +1,12 @@ +import { Plugin } from 'chart.js'; +import MkChartLegend from '@/components/MkChartLegend.vue'; + +export const chartLegend = (legend: InstanceType) => ({ + id: 'htmlLegend', + afterUpdate(chart, args, options) { + // Reuse the built-in legendItems generator + const items = chart.options.plugins.legend.labels.generateLabels(chart); + + legend.update(chart, items); + }, +}) as Plugin; diff --git a/packages/frontend/src/scripts/chart-vline.ts b/packages/frontend/src/scripts/chart-vline.ts index 10021583e0..f321443834 100644 --- a/packages/frontend/src/scripts/chart-vline.ts +++ b/packages/frontend/src/scripts/chart-vline.ts @@ -1,3 +1,5 @@ +import { Plugin } from 'chart.js'; + export const chartVLine = (vLineColor: string) => ({ id: 'vLine', beforeDraw(chart, args, options) { @@ -18,4 +20,4 @@ export const chartVLine = (vLineColor: string) => ({ ctx.restore(); } }, -}); +}) as Plugin; From 2d4d3417a2ac2236af0cb60a2d206c7e229526ee Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 3 Jan 2023 14:17:39 +0900 Subject: [PATCH 18/24] refactor --- .../src/components/MkVisibilityPicker.vue | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/packages/frontend/src/components/MkVisibilityPicker.vue b/packages/frontend/src/components/MkVisibilityPicker.vue index 99b5d93d5f..4c78659f5c 100644 --- a/packages/frontend/src/components/MkVisibilityPicker.vue +++ b/packages/frontend/src/components/MkVisibilityPicker.vue @@ -1,42 +1,42 @@