diff options
| author | かっこかり <67428053+kakkokari-gtyih@users.noreply.github.com> | 2024-09-15 12:20:29 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-15 12:20:29 +0900 |
| commit | e0f54d6a6870036432a35a6a7fd881bb9c5ac178 (patch) | |
| tree | 76c573371fc0637ca25f9dd2d9f2adcb4ae77bc0 /packages/frontend/src/components | |
| parent | refactor(frontend): frontend-embed/src/to-be-sharedを共通化 (#14536) (diff) | |
| download | misskey-e0f54d6a6870036432a35a6a7fd881bb9c5ac178.tar.gz misskey-e0f54d6a6870036432a35a6a7fd881bb9c5ac178.tar.bz2 misskey-e0f54d6a6870036432a35a6a7fd881bb9c5ac178.zip | |
fix(frontend): MkDateSeparatedListで月の違う同じ日はセパレータが出ないのを修正 (#14545)
* fix(frontend): MkDateSeparatedListで月の違う同じ日はセパレータが出ないのを修正
* Update Changelog
Diffstat (limited to 'packages/frontend/src/components')
| -rw-r--r-- | packages/frontend/src/components/MkDateSeparatedList.vue | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/packages/frontend/src/components/MkDateSeparatedList.vue b/packages/frontend/src/components/MkDateSeparatedList.vue index f16981716c..4b94bef4b6 100644 --- a/packages/frontend/src/components/MkDateSeparatedList.vue +++ b/packages/frontend/src/components/MkDateSeparatedList.vue @@ -43,9 +43,9 @@ export default defineComponent({ setup(props, { slots, expose }) { const $style = useCssModule(); // カスタムレンダラなので使っても大丈夫 - function getDateText(time: string) { - const date = new Date(time).getDate(); - const month = new Date(time).getMonth() + 1; + function getDateText(dateInstance: Date) { + const date = dateInstance.getDate(); + const month = dateInstance.getMonth() + 1; return i18n.tsx.monthAndDay({ month: month.toString(), day: date.toString(), @@ -62,9 +62,16 @@ export default defineComponent({ })[0]; if (el.key == null && item.id) el.key = item.id; + const date = new Date(item.createdAt); + const nextDate = props.items[i + 1] ? new Date(props.items[i + 1].createdAt) : null; + if ( i !== props.items.length - 1 && - new Date(item.createdAt).getDate() !== new Date(props.items[i + 1].createdAt).getDate() + nextDate != null && ( + date.getFullYear() !== nextDate.getFullYear() || + date.getMonth() !== nextDate.getMonth() || + date.getDate() !== nextDate.getDate() + ) ) { const separator = h('div', { class: $style['separator'], @@ -78,12 +85,12 @@ export default defineComponent({ h('i', { class: `ti ti-chevron-up ${$style['date-1-icon']}`, }), - getDateText(item.createdAt), + getDateText(date), ]), h('span', { class: $style['date-2'], }, [ - getDateText(props.items[i + 1].createdAt), + getDateText(nextDate), h('i', { class: `ti ti-chevron-down ${$style['date-2-icon']}`, }), |