View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/599 Closes #622 Approved-by: Marie <2-Marie@users.noreply.activitypub.software> Approved-by: Julia Johannesen <julia@insertdomain.name>
This commit is contained in:
commit
d03c9f4b62
@ -43,7 +43,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { computed, ComputedRef, isRef, nextTick, onActivated, onBeforeMount, onBeforeUnmount, onDeactivated, ref, shallowRef, watch } from 'vue';
|
||||
import { computed, ComputedRef, isRef, nextTick, onActivated, onBeforeMount, onBeforeUnmount, onDeactivated, ref, shallowRef, watch, type Ref } from 'vue';
|
||||
import * as Misskey from 'misskey-js';
|
||||
import * as os from '@/os.js';
|
||||
import { misskeyApi } from '@/scripts/misskey-api.js';
|
||||
@ -199,11 +199,17 @@ watch(error, (n, o) => {
|
||||
emit('status', n);
|
||||
});
|
||||
|
||||
function getActualValue<T>(input: T|Ref<T>|undefined, defaultValue: T) : T {
|
||||
if (!input) return defaultValue;
|
||||
if (isRef(input)) return input.value;
|
||||
return input;
|
||||
}
|
||||
|
||||
async function init(): Promise<void> {
|
||||
items.value = new Map();
|
||||
queue.value = new Map();
|
||||
fetching.value = true;
|
||||
const params = props.pagination.params ? isRef(props.pagination.params) ? props.pagination.params.value : props.pagination.params : {};
|
||||
const params = getActualValue<Paging['params']>(props.pagination.params, {});
|
||||
await misskeyApi<MisskeyEntity[]>(props.pagination.endpoint, {
|
||||
...params,
|
||||
limit: props.pagination.limit ?? 10,
|
||||
@ -239,8 +245,8 @@ const reload = (): Promise<void> => {
|
||||
const fetchMore = async (): Promise<void> => {
|
||||
if (!more.value || fetching.value || moreFetching.value || items.value.size === 0) return;
|
||||
moreFetching.value = true;
|
||||
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;
|
||||
const params = getActualValue<Paging['params']>(props.pagination.params, {});
|
||||
const offsetMode = getActualValue(props.pagination.offsetMode, false);
|
||||
await misskeyApi<MisskeyEntity[]>(props.pagination.endpoint, {
|
||||
...params,
|
||||
limit: SECOND_FETCH_LIMIT,
|
||||
@ -304,8 +310,8 @@ const fetchMore = async (): Promise<void> => {
|
||||
const fetchMoreAhead = async (): Promise<void> => {
|
||||
if (!more.value || fetching.value || moreFetching.value || items.value.size === 0) return;
|
||||
moreFetching.value = true;
|
||||
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;
|
||||
const params = getActualValue<Paging['params']>(props.pagination.params, {});
|
||||
const offsetMode = getActualValue(props.pagination.offsetMode, false);
|
||||
await misskeyApi<MisskeyEntity[]>(props.pagination.endpoint, {
|
||||
...params,
|
||||
limit: SECOND_FETCH_LIMIT,
|
||||
|
Loading…
Reference in New Issue
Block a user