Skip to content

Commit

Permalink
refactor: paginationの型を明示する (#12809)
Browse files Browse the repository at this point in the history
* refactor: paginationの型を明示する

* asではなくsatisfiesを使うように
  • Loading branch information
GrapeApple0 authored Dec 26, 2023
1 parent 9022b05 commit 6855079
Show file tree
Hide file tree
Showing 37 changed files with 93 additions and 93 deletions.
4 changes: 2 additions & 2 deletions packages/frontend/src/components/MkFileListForAdmin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ SPDX-License-Identifier: AGPL-3.0-only

<script lang="ts" setup>
import * as Misskey from 'misskey-js';
import MkPagination from '@/components/MkPagination.vue';
import MkPagination, { Paging } from '@/components/MkPagination.vue';
import MkDriveFileThumbnail from '@/components/MkDriveFileThumbnail.vue';
import bytes from '@/filters/bytes.js';
import { i18n } from '@/i18n.js';
import { dateString } from '@/filters/date.js';
const props = defineProps<{
pagination: any;
pagination: Paging;
viewMode: 'grid' | 'list';
}>();
</script>
Expand Down
6 changes: 3 additions & 3 deletions packages/frontend/src/components/MkNoteDetailed.vue
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ import { claimAchievement } from '@/scripts/achievements.js';
import MkRippleEffect from '@/components/MkRippleEffect.vue';
import { showMovedDialog } from '@/scripts/show-moved-dialog.js';
import MkUserCardMini from '@/components/MkUserCardMini.vue';
import MkPagination from '@/components/MkPagination.vue';
import MkPagination, { Paging } from '@/components/MkPagination.vue';
import MkReactionIcon from '@/components/MkReactionIcon.vue';
import MkButton from '@/components/MkButton.vue';
Expand Down Expand Up @@ -307,7 +307,7 @@ const renotesPagination = computed(() => ({
params: {
noteId: appearNote.value.id,
},
}));
} satisfies Paging));
const reactionsPagination = computed(() => ({
endpoint: 'notes/reactions',
Expand All @@ -316,7 +316,7 @@ const reactionsPagination = computed(() => ({
noteId: appearNote.value.id,
type: reactionTabType.value,
},
}));
} satisfies Paging));
useNoteCapture({
rootEl: el,
Expand Down
6 changes: 3 additions & 3 deletions packages/frontend/src/components/MkUserSetupDialog.Follow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ SPDX-License-Identifier: AGPL-3.0-only
import { i18n } from '@/i18n.js';
import MkFolder from '@/components/MkFolder.vue';
import XUser from '@/components/MkUserSetupDialog.User.vue';
import MkPagination from '@/components/MkPagination.vue';
import MkPagination, { Paging } from '@/components/MkPagination.vue';
const pinnedUsers = { endpoint: 'pinned-users', noPaging: true };
const pinnedUsers = { endpoint: 'pinned-users', noPaging: true } satisfies Paging;
const popularUsers = { endpoint: 'users', limit: 10, noPaging: true, params: {
state: 'alive',
origin: 'local',
sort: '+follower',
} };
} } satisfies Paging;
</script>

<style lang="scss" module>
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/pages/about.federation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const pagination = {
state.value === 'notResponding' ? { notResponding: true } :
{}),
})),
} as Paging;
} satisfies Paging;
function getStatus(instance) {
if (instance.isSuspended) return 'Suspended';
Expand Down
4 changes: 2 additions & 2 deletions packages/frontend/src/pages/admin-user.vue
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ import { definePageMetadata } from '@/scripts/page-metadata.js';
import { i18n } from '@/i18n.js';
import { iAmAdmin, $i } from '@/account.js';
import MkRolePreview from '@/components/MkRolePreview.vue';
import MkPagination from '@/components/MkPagination.vue';
import MkPagination, { Paging } from '@/components/MkPagination.vue';
const props = withDefaults(defineProps<{
userId: string;
Expand Down Expand Up @@ -258,7 +258,7 @@ const announcementsPagination = {
params: computed(() => ({
userId: props.userId,
})),
};
} satisfies Paging;
const expandedRoles = ref([]);
function createFetcher() {
Expand Down
4 changes: 2 additions & 2 deletions packages/frontend/src/pages/admin/abuses.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import { computed, shallowRef, ref } from 'vue';
import XHeader from './_header_.vue';
import MkSelect from '@/components/MkSelect.vue';
import MkPagination from '@/components/MkPagination.vue';
import MkPagination, { Paging } from '@/components/MkPagination.vue';
import XAbuseReport from '@/components/MkAbuseReport.vue';
import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js';
Expand All @@ -77,7 +77,7 @@ const pagination = {
reporterOrigin: reporterOrigin.value,
targetUserOrigin: targetUserOrigin.value,
})),
};
} satisfies Paging;
function resolved(reportId) {
reports.value.removeItem(reportId);
Expand Down
4 changes: 2 additions & 2 deletions packages/frontend/src/pages/admin/federation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ import { computed, ref } from 'vue';
import XHeader from './_header_.vue';
import MkInput from '@/components/MkInput.vue';
import MkSelect from '@/components/MkSelect.vue';
import MkPagination from '@/components/MkPagination.vue';
import MkPagination, { Paging } from '@/components/MkPagination.vue';
import MkInstanceCardMini from '@/components/MkInstanceCardMini.vue';
import FormSplit from '@/components/form/split.vue';
import { i18n } from '@/i18n.js';
Expand All @@ -88,7 +88,7 @@ const pagination = {
state.value === 'notResponding' ? { notResponding: true } :
{}),
})),
};
} satisfies Paging;
function getStatus(instance) {
if (instance.isSuspended) return 'Suspended';
Expand Down
8 changes: 4 additions & 4 deletions packages/frontend/src/pages/admin/invites.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ const pagingComponent = shallowRef<InstanceType<typeof MkPagination>>();
const type = ref('all');
const sort = ref('+createdAt');
const pagination: Paging = {
const pagination = {
endpoint: 'admin/invite/list' as const,
limit: 10,
params: computed(() => ({
type: type.value,
sort: sort.value,
})),
offsetMode: true,
};
} satisfies Paging;
const expiresAt = ref('');
const noExpirationDate = ref(true);
Expand All @@ -97,10 +97,10 @@ async function createWithOptions() {
os.alert({
type: 'success',
title: i18n.ts.inviteCodeCreated,
text: tickets?.map(x => x.code).join('\n'),
text: tickets.map(x => x.code).join('\n'),
});
tickets?.forEach(ticket => pagingComponent.value?.prepend(ticket));
tickets.forEach(ticket => pagingComponent.value?.prepend(ticket));
}
function deleted(id: string) {
Expand Down
4 changes: 2 additions & 2 deletions packages/frontend/src/pages/admin/modlog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import XHeader from './_header_.vue';
import XModLog from './modlog.ModLog.vue';
import MkSelect from '@/components/MkSelect.vue';
import MkInput from '@/components/MkInput.vue';
import MkPagination from '@/components/MkPagination.vue';
import MkPagination, { Paging } from '@/components/MkPagination.vue';
import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js';

Expand All @@ -52,7 +52,7 @@ const pagination = {
type: type.value,
userId: moderatorId.value === '' ? null : moderatorId.value,
})),
};
} satisfies Paging;

console.log(Misskey);

Expand Down
4 changes: 2 additions & 2 deletions packages/frontend/src/pages/admin/roles.role.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ import { useRouter } from '@/router.js';
import MkButton from '@/components/MkButton.vue';
import MkUserCardMini from '@/components/MkUserCardMini.vue';
import MkInfo from '@/components/MkInfo.vue';
import MkPagination from '@/components/MkPagination.vue';
import MkPagination, { Paging } from '@/components/MkPagination.vue';
import { infoImageUrl } from '@/instance.js';
const router = useRouter();
Expand All @@ -88,7 +88,7 @@ const usersPagination = {
params: computed(() => ({
roleId: props.id,
})),
};
} satisfies Paging;
const expandedItems = ref([]);
Expand Down
4 changes: 2 additions & 2 deletions packages/frontend/src/pages/admin/users.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ import { computed, shallowRef, ref } from 'vue';
import XHeader from './_header_.vue';
import MkInput from '@/components/MkInput.vue';
import MkSelect from '@/components/MkSelect.vue';
import MkPagination from '@/components/MkPagination.vue';
import MkPagination, { Paging } from '@/components/MkPagination.vue';
import * as os from '@/os.js';
import { lookupUser } from '@/scripts/lookup-user.js';
import { i18n } from '@/i18n.js';
Expand All @@ -87,7 +87,7 @@ const pagination = {
hostname: searchHost.value,
})),
offsetMode: true,
};
} satisfies Paging;
function searchUser() {
os.selectUser().then(user => {
Expand Down
6 changes: 3 additions & 3 deletions packages/frontend/src/pages/announcements.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup>
import { ref, computed } from 'vue';
import MkPagination from '@/components/MkPagination.vue';
import MkPagination, { Paging } from '@/components/MkPagination.vue';
import MkButton from '@/components/MkButton.vue';
import MkInfo from '@/components/MkInfo.vue';
import * as os from '@/os.js';
Expand All @@ -55,15 +55,15 @@ const paginationCurrent = {
params: {
isActive: true,
},
};
} satisfies Paging;
const paginationPast = {
endpoint: 'announcements' as const,
limit: 10,
params: {
isActive: false,
},
};
} satisfies Paging;
const paginationEl = ref<InstanceType<typeof MkPagination>>();
Expand Down
10 changes: 5 additions & 5 deletions packages/frontend/src/pages/channels.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ SPDX-License-Identifier: AGPL-3.0-only
import { computed, onMounted, ref } from 'vue';
import MkChannelPreview from '@/components/MkChannelPreview.vue';
import MkChannelList from '@/components/MkChannelList.vue';
import MkPagination from '@/components/MkPagination.vue';
import MkPagination, { Paging } from '@/components/MkPagination.vue';
import MkInput from '@/components/MkInput.vue';
import MkRadios from '@/components/MkRadios.vue';
import MkButton from '@/components/MkButton.vue';
Expand Down Expand Up @@ -83,20 +83,20 @@ onMounted(() => {
const featuredPagination = {
endpoint: 'channels/featured' as const,
noPaging: true,
};
} satisfies Paging;
const favoritesPagination = {
endpoint: 'channels/my-favorites' as const,
limit: 100,
noPaging: true,
};
} satisfies Paging;
const followingPagination = {
endpoint: 'channels/followed' as const,
limit: 10,
};
} satisfies Paging;
const ownedPagination = {
endpoint: 'channels/owned' as const,
limit: 10,
};
} satisfies Paging;
async function search() {
const query = searchQuery.value.toString().trim();
Expand Down
6 changes: 3 additions & 3 deletions packages/frontend/src/pages/custom-emojis-manager.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ SPDX-License-Identifier: AGPL-3.0-only
import { computed, defineAsyncComponent, ref, shallowRef } from 'vue';
import MkButton from '@/components/MkButton.vue';
import MkInput from '@/components/MkInput.vue';
import MkPagination from '@/components/MkPagination.vue';
import MkPagination, { Paging } from '@/components/MkPagination.vue';
import MkSwitch from '@/components/MkSwitch.vue';
import FormSplit from '@/components/form/split.vue';
import { selectFile } from '@/scripts/select-file.js';
Expand All @@ -100,7 +100,7 @@ const pagination = {
params: computed(() => ({
query: (query.value && query.value !== '') ? query.value : null,
})),
};
} satisfies Paging;
const remotePagination = {
endpoint: 'admin/emoji/list-remote' as const,
Expand All @@ -109,7 +109,7 @@ const remotePagination = {
query: (queryRemote.value && queryRemote.value !== '') ? queryRemote.value : null,
host: (host.value && host.value !== '') ? host.value : null,
})),
};
} satisfies Paging;
const selectAll = () => {
if (selectedEmojis.value.length > 0) {
Expand Down
4 changes: 2 additions & 2 deletions packages/frontend/src/pages/favorites.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</template>

<script lang="ts" setup>
import MkPagination from '@/components/MkPagination.vue';
import MkPagination, { Paging } from '@/components/MkPagination.vue';
import MkNote from '@/components/MkNote.vue';
import MkDateSeparatedList from '@/components/MkDateSeparatedList.vue';
import { i18n } from '@/i18n.js';
Expand All @@ -36,7 +36,7 @@ import { infoImageUrl } from '@/instance.js';
const pagination = {
endpoint: 'i/favorites' as const,
limit: 10,
};
} satisfies Paging;
definePageMetadata({
title: i18n.ts.favorites,
Expand Down
8 changes: 4 additions & 4 deletions packages/frontend/src/pages/flash/flash-index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup>
import { computed, ref } from 'vue';
import MkFlashPreview from '@/components/MkFlashPreview.vue';
import MkPagination from '@/components/MkPagination.vue';
import MkPagination, { Paging } from '@/components/MkPagination.vue';
import MkButton from '@/components/MkButton.vue';
import { useRouter } from '@/router.js';
import { i18n } from '@/i18n.js';
Expand All @@ -53,15 +53,15 @@ const tab = ref('featured');
const featuredFlashsPagination = {
endpoint: 'flash/featured' as const,
noPaging: true,
};
} satisfies Paging;
const myFlashsPagination = {
endpoint: 'flash/my' as const,
limit: 5,
};
} satisfies Paging;
const likedFlashsPagination = {
endpoint: 'flash/my-likes' as const,
limit: 5,
};
} satisfies Paging;
function create() {
router.push('/play/new');
Expand Down
4 changes: 2 additions & 2 deletions packages/frontend/src/pages/follow-requests.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ SPDX-License-Identifier: AGPL-3.0-only

<script lang="ts" setup>
import { shallowRef, computed } from 'vue';
import MkPagination from '@/components/MkPagination.vue';
import MkPagination, { Paging } from '@/components/MkPagination.vue';
import MkButton from '@/components/MkButton.vue';
import { userPage, acct } from '@/filters/user.js';
import * as os from '@/os.js';
Expand All @@ -51,7 +51,7 @@ const paginationComponent = shallowRef<InstanceType<typeof MkPagination>>();
const pagination = {
endpoint: 'following/requests/list' as const,
limit: 10,
};
} satisfies Paging;
function accept(user) {
os.api('following/requests/accept', { userId: user.id }).then(() => {
Expand Down
Loading

0 comments on commit 6855079

Please sign in to comment.