Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(frontend): 「今日誕生日のフォロー中ユーザー」ウィジェットが正しく動作しない問題を修正 #12835

Merged
merged 21 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
9ce9a5c
(fix) タイムゾーンによっては誕生日のフォロー中ユーザーが正しく読み込まれない
kakkokari-gtyih Dec 28, 2023
c5ab641
文言をわかりやすく
kakkokari-gtyih Dec 28, 2023
8250c75
Update Changelog
kakkokari-gtyih Dec 28, 2023
9ac5105
(add) reload button
kakkokari-gtyih Dec 28, 2023
8f26f6e
Update CHANGELOG.md
kakkokari-gtyih Dec 28, 2023
2d0fc72
Merge branch 'develop' into fix-bday-widget-tz
kakkokari-gtyih Jan 1, 2024
98af1cb
Merge branch 'develop' into fix-bday-widget-tz
kakkokari-gtyih Jan 2, 2024
5e749a1
Merge branch 'develop' into fix-bday-widget-tz
kakkokari-gtyih Jan 15, 2024
7669bba
Merge branch 'develop' into fix-bday-widget-tz
kakkokari-gtyih Jan 24, 2024
b1e1e3b
run misskey-js
kakkokari-gtyih Jan 24, 2024
d6c24f1
fix
kakkokari-gtyih Jan 24, 2024
5599d0e
Merge branch 'develop' into fix-bday-widget-tz
kakkokari-gtyih Feb 6, 2024
e48f84e
Merge branch 'develop' into fix-bday-widget-tz
kakkokari-gtyih Feb 15, 2024
c90d512
Merge branch 'develop' into fix-bday-widget-tz
kakkokari-gtyih Mar 4, 2024
7c12bad
Merge branch 'develop' into fix-bday-widget-tz
kakkokari-gtyih Mar 12, 2024
a09b8e5
Merge branch 'develop' into fix-bday-widget-tz
kakkokari-gtyih Mar 13, 2024
b59c577
Merge branch 'develop' into fix-bday-widget-tz
kakkokari-gtyih Mar 17, 2024
57b1ded
Merge branch 'develop' into fix-bday-widget-tz
kakkokari-gtyih Mar 25, 2024
24c747b
Revert "文言をわかりやすく"
kakkokari-gtyih Mar 25, 2024
69aaa39
Update packages/frontend/src/widgets/WidgetBirthdayFollowings.vue
syuilo Mar 25, 2024
8363efe
Update packages/frontend/src/widgets/WidgetBirthdayFollowings.vue
syuilo Mar 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- 実装の都合により、プラグインは1つエラーを起こした時に即時停止するようになりました
- Enhance: ページのデザインを変更
- Enhance: 2要素認証(ワンタイムパスワード)の入力欄を改善
- Enhance: 「今日誕生日のフォロー中ユーザー」ウィジェットを手動でリロードできるように
- Fix: 一部のページ内リンクが正しく動作しない問題を修正
- Fix: 周年の実績が閏年を考慮しない問題を修正
- Fix: ローカルURLのプレビューポップアップが左上に表示される
Expand All @@ -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`のみに
Expand Down
7 changes: 3 additions & 4 deletions packages/backend/src/server/api/endpoints/users/following.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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'] },
Expand Down Expand Up @@ -127,9 +128,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // 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}'`);
Comment on lines +131 to 134
Copy link
Contributor Author

@kakkokari-gtyih kakkokari-gtyih Dec 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

一応入力のタイミングでbirthdaySchemaの正規表現バリデーションを挟んではいるものの、クエリに直接値を突っ込んでるので心配(L134でSQLのパラメータ記法はなぜか動かなかった)

Expand Down
35 changes: 26 additions & 9 deletions packages/frontend/src/widgets/WidgetBirthdayFollowings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<MkContainer :showHeader="widgetProps.showHeader" class="mkw-bdayfollowings">
<template #icon><i class="ti ti-cake"></i></template>
<template #header>{{ i18n.ts._widgets.birthdayFollowings }}</template>
<template #func="{ buttonStyleClass }"><button class="_button" :class="buttonStyleClass" @click="actualFetch()"><i class="ti ti-refresh"></i></button></template>

<div :class="$style.bdayFRoot">
<MkLoading v-if="fetching"/>
Expand Down Expand Up @@ -53,7 +54,7 @@ const { widgetProps, configure } = useWidgetPropsManager(name,
emit,
);

const users = ref<Misskey.entities.FollowingFolloweePopulated[]>([]);
const users = ref<Misskey.Endpoints['users/following']['res']>([]);
const fetching = ref(true);
let lastFetchedAt = '1970-01-01';

Expand All @@ -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,
Expand Down
Loading