mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-27 02:03:09 +02:00
allow computed offsetMode
in MkPagination
- #490
This commit is contained in:
parent
bb7b4a8ea4
commit
c88de91b1a
1 changed files with 5 additions and 3 deletions
|
@ -73,7 +73,7 @@ export type Paging<E extends keyof Misskey.Endpoints = keyof Misskey.Endpoints>
|
||||||
*/
|
*/
|
||||||
reversed?: boolean;
|
reversed?: boolean;
|
||||||
|
|
||||||
offsetMode?: boolean;
|
offsetMode?: boolean | ComputedRef<boolean>;
|
||||||
|
|
||||||
pageEl?: HTMLElement;
|
pageEl?: HTMLElement;
|
||||||
};
|
};
|
||||||
|
@ -240,10 +240,11 @@ const fetchMore = async (): Promise<void> => {
|
||||||
if (!more.value || fetching.value || moreFetching.value || items.value.size === 0) return;
|
if (!more.value || fetching.value || moreFetching.value || items.value.size === 0) return;
|
||||||
moreFetching.value = true;
|
moreFetching.value = true;
|
||||||
const params = props.pagination.params ? isRef(props.pagination.params) ? props.pagination.params.value : props.pagination.params : {};
|
const params = props.pagination.params ? isRef(props.pagination.params) ? props.pagination.params.value : props.pagination.params : {};
|
||||||
|
const offsetMode = props.offsetMode ? isRef(props.offsetMode) ? props.offsetMode.value : props.offsetMode : false;
|
||||||
await misskeyApi<MisskeyEntity[]>(props.pagination.endpoint, {
|
await misskeyApi<MisskeyEntity[]>(props.pagination.endpoint, {
|
||||||
...params,
|
...params,
|
||||||
limit: SECOND_FETCH_LIMIT,
|
limit: SECOND_FETCH_LIMIT,
|
||||||
...(props.pagination.offsetMode ? {
|
...(offsetMode ? {
|
||||||
offset: offset.value,
|
offset: offset.value,
|
||||||
} : {
|
} : {
|
||||||
untilId: Array.from(items.value.keys()).at(-1),
|
untilId: Array.from(items.value.keys()).at(-1),
|
||||||
|
@ -304,10 +305,11 @@ const fetchMoreAhead = async (): Promise<void> => {
|
||||||
if (!more.value || fetching.value || moreFetching.value || items.value.size === 0) return;
|
if (!more.value || fetching.value || moreFetching.value || items.value.size === 0) return;
|
||||||
moreFetching.value = true;
|
moreFetching.value = true;
|
||||||
const params = props.pagination.params ? isRef(props.pagination.params) ? props.pagination.params.value : props.pagination.params : {};
|
const params = props.pagination.params ? isRef(props.pagination.params) ? props.pagination.params.value : props.pagination.params : {};
|
||||||
|
const offsetMode = props.offsetMode ? isRef(props.offsetMode) ? props.offsetMode.value : props.offsetMode : false;
|
||||||
await misskeyApi<MisskeyEntity[]>(props.pagination.endpoint, {
|
await misskeyApi<MisskeyEntity[]>(props.pagination.endpoint, {
|
||||||
...params,
|
...params,
|
||||||
limit: SECOND_FETCH_LIMIT,
|
limit: SECOND_FETCH_LIMIT,
|
||||||
...(props.pagination.offsetMode ? {
|
...(offsetMode ? {
|
||||||
offset: offset.value,
|
offset: offset.value,
|
||||||
} : {
|
} : {
|
||||||
sinceId: Array.from(items.value.keys()).at(-1),
|
sinceId: Array.from(items.value.keys()).at(-1),
|
||||||
|
|
Loading…
Reference in a new issue