From f90be427f51392ef3ed5a7eb7f35059274bb47fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=8B=E3=81=A3=E3=81=93=E3=81=8B=E3=82=8A?= <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Mon, 25 Mar 2024 18:31:30 +0900 Subject: [PATCH] =?UTF-8?q?fix(frontend):=20=E3=80=8C=E4=BB=8A=E6=97=A5?= =?UTF-8?q?=E8=AA=95=E7=94=9F=E6=97=A5=E3=81=AE=E3=83=95=E3=82=A9=E3=83=AD?= =?UTF-8?q?=E3=83=BC=E4=B8=AD=E3=83=A6=E3=83=BC=E3=82=B6=E3=83=BC=E3=80=8D?= =?UTF-8?q?=E3=82=A6=E3=82=A3=E3=82=B8=E3=82=A7=E3=83=83=E3=83=88=E3=81=8C?= =?UTF-8?q?=E6=AD=A3=E3=81=97=E3=81=8F=E5=8B=95=E4=BD=9C=E3=81=97=E3=81=AA?= =?UTF-8?q?=E3=81=84=E5=95=8F=E9=A1=8C=E3=82=92=E4=BF=AE=E6=AD=A3=20(#1283?= =?UTF-8?q?5)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * (fix) タイムゾーンによっては誕生日のフォロー中ユーザーが正しく読み込まれない * 文言をわかりやすく * Update Changelog * (add) reload button * Update CHANGELOG.md * run misskey-js * fix * Revert "文言をわかりやすく" This reverts commit c5ab6419563cc70ec8ba758e800c74d3469131e3. * Update packages/frontend/src/widgets/WidgetBirthdayFollowings.vue * Update packages/frontend/src/widgets/WidgetBirthdayFollowings.vue --------- Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com> --- CHANGELOG.md | 2 ++ .../server/api/endpoints/users/following.ts | 7 ++-- .../src/widgets/WidgetBirthdayFollowings.vue | 35 ++++++++++++++----- 3 files changed, 31 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d90b1425c1..f41ff2171f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ - 実装の都合により、プラグインは1つエラーを起こした時に即時停止するようになりました - Enhance: ページのデザインを変更 - Enhance: 2要素認証(ワンタイムパスワード)の入力欄を改善 +- Enhance: 「今日誕生日のフォロー中ユーザー」ウィジェットを手動でリロードできるように - Fix: 一部のページ内リンクが正しく動作しない問題を修正 - Fix: 周年の実績が閏年を考慮しない問題を修正 - Fix: ローカルURLのプレビューポップアップが左上に表示される @@ -27,6 +28,7 @@ (Cherry-picked from https://github.com/MisskeyIO/misskey/pull/528) - Fix: コードブロックのシンタックスハイライトで使用される定義ファイルをCDNから取得するように #13177 - CDNから取得せずMisskey本体にバンドルする場合は`pacakges/frontend/vite.config.ts`を修正してください。 +- Fix: タイムゾーンによっては、「今日誕生日のフォロー中ユーザー」ウィジェットが正しく動作しない問題を修正 ### Server - Enhance: エンドポイント`antennas/update`の必須項目を`antennaId`のみに diff --git a/packages/backend/src/server/api/endpoints/users/following.ts b/packages/backend/src/server/api/endpoints/users/following.ts index 5d52ebba76..6b3389f0b2 100644 --- a/packages/backend/src/server/api/endpoints/users/following.ts +++ b/packages/backend/src/server/api/endpoints/users/following.ts @@ -6,6 +6,7 @@ import { IsNull } from 'typeorm'; import { Inject, Injectable } from '@nestjs/common'; import type { UsersRepository, FollowingsRepository, UserProfilesRepository } from '@/models/_.js'; +import { birthdaySchema } from '@/models/User.js'; import { Endpoint } from '@/server/api/endpoint-base.js'; import { QueryService } from '@/core/QueryService.js'; import { FollowingEntityService } from '@/core/entities/FollowingEntityService.js'; @@ -66,7 +67,7 @@ export const paramDef = { description: 'The local host is represented with `null`.', }, - birthday: { type: 'string', nullable: true }, + birthday: { ...birthdaySchema, nullable: true }, }, anyOf: [ { required: ['userId'] }, @@ -127,9 +128,7 @@ export default class extends Endpoint { // eslint- if (ps.birthday) { try { - const d = new Date(ps.birthday); - d.setHours(0, 0, 0, 0); - const birthday = `${(d.getMonth() + 1).toString().padStart(2, '0')}-${d.getDate().toString().padStart(2, '0')}`; + const birthday = ps.birthday.substring(5, 10); const birthdayUserQuery = this.userProfilesRepository.createQueryBuilder('user_profile'); birthdayUserQuery.select('user_profile.userId') .where(`SUBSTR(user_profile.birthday, 6, 5) = '${birthday}'`); diff --git a/packages/frontend/src/widgets/WidgetBirthdayFollowings.vue b/packages/frontend/src/widgets/WidgetBirthdayFollowings.vue index 5b448e2c3b..49fd103d37 100644 --- a/packages/frontend/src/widgets/WidgetBirthdayFollowings.vue +++ b/packages/frontend/src/widgets/WidgetBirthdayFollowings.vue @@ -7,6 +7,7 @@ SPDX-License-Identifier: AGPL-3.0-only +
@@ -53,7 +54,7 @@ const { widgetProps, configure } = useWidgetPropsManager(name, emit, ); -const users = ref([]); +const users = ref([]); const fetching = ref(true); let lastFetchedAt = '1970-01-01'; @@ -70,19 +71,35 @@ const fetch = () => { now.setHours(0, 0, 0, 0); if (now > lfAtD) { - misskeyApi('users/following', { - limit: 18, - birthday: now.toISOString(), - userId: $i.id, - }).then(res => { - users.value = res; - fetching.value = false; - }); + actualFetch(); lastFetchedAt = now.toISOString(); } }; +function actualFetch() { + if ($i == null) { + users.value = []; + fetching.value = false; + return; + } + + const now = new Date(); + now.setHours(0, 0, 0, 0); + fetching.value = true; + misskeyApi('users/following', { + limit: 18, + birthday: `${now.getFullYear().toString().padStart(4, '0')}-${(now.getMonth() + 1).toString().padStart(2, '0')}-${now.getDate().toString().padStart(2, '0')}`, + userId: $i.id, + }).then(res => { + users.value = res; + window.setTimeout(() => { + // 早すぎるとチカチカする + fetching.value = false; + }, 100); + }); +} + useInterval(fetch, 1000 * 60, { immediate: true, afterMounted: true,