From 92d9946f597c2b06552b23ba370708aea86575c0 Mon Sep 17 00:00:00 2001 From: tamaina Date: Wed, 5 Jul 2023 00:59:37 +0900 Subject: [PATCH] enhance(frontend): Better Timeline(MkPagination) Experience (#11066) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * enhance(frontend): Better MkPagination Appearance * fix * fix * 新規投稿が空でも先頭に戻ったらunshiftItemsする * use Map * refactor, 型エラー潰し * refactor --- .../frontend/src/components/MkPagination.vue | 170 +++++++++++++----- packages/frontend/src/pages/admin/abuses.vue | 2 +- .../src/pages/custom-emojis-manager.vue | 2 +- 3 files changed, 127 insertions(+), 47 deletions(-) diff --git a/packages/frontend/src/components/MkPagination.vue b/packages/frontend/src/components/MkPagination.vue index 598529bf5..b361d568e 100644 --- a/packages/frontend/src/components/MkPagination.vue +++ b/packages/frontend/src/components/MkPagination.vue @@ -21,14 +21,14 @@
- + {{ i18n.ts.loadMore }}
- +
- + {{ i18n.ts.loadMore }} @@ -50,6 +50,7 @@ import { i18n } from '@/i18n'; const SECOND_FETCH_LIMIT = 30; const TOLERANCE = 16; +const APPEAR_MINIMUM_INTERVAL = 600; export type Paging = { endpoint: E; @@ -71,6 +72,16 @@ export type Paging pageEl?: HTMLElement; }; + +type MisskeyEntityMap = Map; + +function arrayToEntries(entities: MisskeyEntity[]): [string, MisskeyEntity][] { + return entities.map(en => [en.id, en]); +} + +function concatMapWithArray(map: MisskeyEntityMap, entities: MisskeyEntity[]): MisskeyEntityMap { + return new Map([...map, ...arrayToEntries(entities)]); +}