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

enhance: MisskeyIO#529 の追加修正 #536

Merged
merged 1 commit into from
Mar 18, 2024
Merged
Changes from all commits
Commits
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
enhance: #529 の追加修正
Co-authored-by: kakkokari-gtyih <[email protected]>
u1-liquid and kakkokari-gtyih committed Mar 18, 2024

Verified

This commit was signed with the committer’s verified signature.
commit acacd88d3ff9c8375ea419cbd08b421ef9b5d28a
6 changes: 0 additions & 6 deletions packages/frontend/src/components/MkDateSeparatedList.vue
Original file line number Diff line number Diff line change
@@ -134,7 +134,6 @@ export default defineComponent({
const classes = {
[$style['date-separated-list']]: true,
[$style['date-separated-list-nogap']]: props.noGap,
[$style['reversed']]: props.reversed,
[$style['direction-down']]: props.direction === 'down',
[$style['direction-up']]: props.direction === 'up',
};
@@ -211,11 +210,6 @@ export default defineComponent({
}
}

.reversed {
display: flex;
flex-direction: column-reverse;
}

.separator {
text-align: center;
}
32 changes: 16 additions & 16 deletions packages/frontend/src/components/MkPagination.vue
Original file line number Diff line number Diff line change
@@ -25,14 +25,14 @@ SPDX-License-Identifier: AGPL-3.0-only
</div>

<div v-else ref="rootEl">
<div v-show="pagination.reversed && more" key="_more_" class="_margin">
<div v-show="pagination.prepend && more" key="_more_" class="_margin">
<MkButton v-if="!moreFetching" v-appear="(enableInfiniteScroll && !props.disableAutoLoad) ? fetchMoreAhead : null" :class="$style.more" :disabled="moreFetching" :style="{ cursor: moreFetching ? 'wait' : 'pointer' }" primary rounded @click="fetchMoreAhead">
{{ i18n.ts.loadMore }}
</MkButton>
<MkLoading v-else class="loading"/>
</div>
<slot :items="items" :fetching="fetching || moreFetching"></slot>
<div v-show="!pagination.reversed && more" key="_more_" class="_margin">
<div v-show="!pagination.prepend && more" key="_more_" class="_margin">
<MkButton v-if="!moreFetching" v-appear="(enableInfiniteScroll && !props.disableAutoLoad) ? fetchMore : null" :class="$style.more" :disabled="moreFetching" :style="{ cursor: moreFetching ? 'wait' : 'pointer' }" primary rounded @click="fetchMore">
{{ i18n.ts.loadMore }}
</MkButton>
@@ -67,9 +67,9 @@ export type Paging<E extends keyof Misskey.Endpoints = keyof Misskey.Endpoints>
noPaging?: boolean;

/**
* items 配列の中身を逆順にする(新しい方が最後)
* fetchの際に、 items 配列を上方向に追加していく(append, prepend等の関数には影響しない)
*/
reversed?: boolean;
prepend?: boolean;

offsetMode?: boolean;

@@ -126,14 +126,14 @@ const BACKGROUND_PAUSE_WAIT_SEC = 10;
// https://qiita.com/mkataigi/items/0154aefd2223ce23398e
const scrollObserver = ref<IntersectionObserver>();

watch([() => props.pagination.reversed, scrollableElement], () => {
watch([() => props.pagination.prepend, scrollableElement], () => {
if (scrollObserver.value) scrollObserver.value.disconnect();

scrollObserver.value = new IntersectionObserver(entries => {
backed.value = entries[0].isIntersecting;
}, {
root: scrollableElement.value,
rootMargin: props.pagination.reversed ? '-100% 0px 100% 0px' : '100% 0px -100% 0px',
rootMargin: props.pagination.prepend ? '-100% 0px 100% 0px' : '100% 0px -100% 0px',
threshold: 0.01,
});
}, { immediate: true });
@@ -149,7 +149,7 @@ watch([backed, contentEl], () => {
if (!backed.value) {
if (!contentEl.value) return;

scrollRemove.value = (props.pagination.reversed ? onScrollBottom : onScrollTop)(contentEl.value, executeQueue, TOLERANCE);
scrollRemove.value = (props.pagination.prepend ? onScrollBottom : onScrollTop)(contentEl.value, executeQueue, TOLERANCE);
} else {
if (scrollRemove.value) scrollRemove.value();
scrollRemove.value = null;
@@ -187,7 +187,7 @@ async function init(): Promise<void> {
items.value = res;
more.value = false;
} else {
if (props.pagination.reversed) moreFetching.value = true;
if (props.pagination.prepend) moreFetching.value = true;
items.value = res;
more.value = true;
}
@@ -242,7 +242,7 @@ const fetchMore = async (): Promise<void> => {
};

if (res.length === 0) {
if (props.pagination.reversed) {
if (props.pagination.prepend) {
reverseConcat(res).then(() => {
more.value = false;
moreFetching.value = false;
@@ -253,7 +253,7 @@ const fetchMore = async (): Promise<void> => {
moreFetching.value = false;
}
} else {
if (props.pagination.reversed) {
if (props.pagination.prepend) {
reverseConcat(res).then(() => {
more.value = true;
moreFetching.value = false;
@@ -280,14 +280,14 @@ const fetchMoreAhead = async (): Promise<void> => {
...(props.pagination.offsetMode ? {
offset: offset.value,
} : {
sinceId: items.value[items.value.length - 1].id,
sinceId: items.value[0].id,
}),
}).then(res => {
if (res.length === 0) {
items.value = items.value.concat(res);
items.value = res.concat(items.value);
more.value = false;
} else {
items.value = items.value.concat(res);
items.value = res.concat(items.value);
more.value = true;
}
offset.value += res.length;
@@ -297,7 +297,7 @@ const fetchMoreAhead = async (): Promise<void> => {
});
};

const isTop = (): boolean => isBackTop.value || (props.pagination.reversed ? isBottomVisible : isTopVisible)(contentEl.value!, TOLERANCE);
const isTop = (): boolean => isBackTop.value || (props.pagination.prepend ? isBottomVisible : isTopVisible)(contentEl.value!, TOLERANCE);

watch(visibility, () => {
if (visibility.value === 'hidden') {
@@ -369,7 +369,7 @@ onActivated(() => {
});

onDeactivated(() => {
isBackTop.value = props.pagination.reversed ? window.scrollY >= (rootEl.value ? rootEl.value.scrollHeight - window.innerHeight : 0) : window.scrollY === 0;
isBackTop.value = props.pagination.prepend ? window.scrollY >= (rootEl.value ? rootEl.value.scrollHeight - window.innerHeight : 0) : window.scrollY === 0;
});

function toBottom() {
@@ -378,7 +378,7 @@ function toBottom() {

onBeforeMount(() => {
init().then(() => {
if (props.pagination.reversed) {
if (props.pagination.prepend) {
nextTick(() => {
setTimeout(toBottom, 800);

2 changes: 2 additions & 0 deletions packages/frontend/src/pages/note.vue
Original file line number Diff line number Diff line change
@@ -85,6 +85,7 @@ const prevUserPagination: Paging = {
};

const nextUserPagination: Paging = {
prepend: true,
endpoint: 'users/notes',
limit: 10,
params: computed(() => note.value ? ({
@@ -103,6 +104,7 @@ const prevChannelPagination: Paging = {
};

const nextChannelPagination: Paging = {
prepend: true,
endpoint: 'channels/timeline',
limit: 10,
params: computed(() => note.value ? ({

Unchanged files with check annotations Beta

};
export function parse(acct: string): Acct {
if (acct.startsWith('@')) acct = acct.substring(1);

Check warning on line 7 in packages/misskey-js/src/acct.ts

GitHub Actions / lint (misskey-js)

Assignment to function parameter 'acct'
const split = acct.split('@', 2);
return { username: split[0], host: split[1] || null };
}
code: string;
message: string;
kind: 'client' | 'server';
info: Record<string, any>;

Check warning on line 17 in packages/misskey-js/src/api.ts

GitHub Actions / lint (misskey-js)

Unexpected any. Specify a different type
};
export function isAPIError(reason: Record<PropertyKey, unknown>): reason is APIError {
headers: { [key in string]: string }
}) => Promise<{
status: number;
json(): Promise<any>;

Check warning on line 32 in packages/misskey-js/src/api.ts

GitHub Actions / lint (misskey-js)

Unexpected any. Specify a different type
}>;
export class APIClient {
type IsCaseMatched<E extends keyof Endpoints, P extends Endpoints[E]['req'], C extends number> =
Endpoints[E]['res'] extends SwitchCase
? IsNeverType<StrictExtract<Endpoints[E]['res']['$switch']['$cases'][C], [P, any]>> extends false ? true : false

Check warning on line 30 in packages/misskey-js/src/api.types.ts

GitHub Actions / lint (misskey-js)

Unexpected any. Specify a different type
: false
type GetCaseResult<E extends keyof Endpoints, P extends Endpoints[E]['req'], C extends number> =
Endpoints[E]['res'] extends SwitchCase
? StrictExtract<Endpoints[E]['res']['$switch']['$cases'][C], [P, any]>[1]

Check warning on line 35 in packages/misskey-js/src/api.types.ts

GitHub Actions / lint (misskey-js)

Unexpected any. Specify a different type
: never
export type SwitchCaseResponseType<E extends keyof Endpoints, P extends Endpoints[E]['req']> = Endpoints[E]['res'] extends SwitchCase
export type ModerationLogPayloads = {
updateServerSettings: {
before: any | null;

Check warning on line 151 in packages/misskey-js/src/consts.ts

GitHub Actions / lint (misskey-js)

Unexpected any. Specify a different type
after: any | null;

Check warning on line 152 in packages/misskey-js/src/consts.ts

GitHub Actions / lint (misskey-js)

Unexpected any. Specify a different type
};
suspend: {
userId: string;
};
addCustomEmoji: {
emojiId: string;
emoji: any;

Check warning on line 173 in packages/misskey-js/src/consts.ts

GitHub Actions / lint (misskey-js)

Unexpected any. Specify a different type
};
updateCustomEmoji: {
emojiId: string;
before: any;

Check warning on line 177 in packages/misskey-js/src/consts.ts

GitHub Actions / lint (misskey-js)

Unexpected any. Specify a different type
after: any;

Check warning on line 178 in packages/misskey-js/src/consts.ts

GitHub Actions / lint (misskey-js)

Unexpected any. Specify a different type
};
deleteCustomEmoji: {
emojiId: string;