summaryrefslogtreecommitdiff
path: root/packages/frontend/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/frontend/src')
-rw-r--r--packages/frontend/src/components/MkButton.vue9
-rw-r--r--packages/frontend/src/components/MkPagination.vue43
-rw-r--r--packages/frontend/src/composables/use-pagination.ts13
3 files changed, 50 insertions, 15 deletions
diff --git a/packages/frontend/src/components/MkButton.vue b/packages/frontend/src/components/MkButton.vue
index 891af7f696..a77ebd6ac5 100644
--- a/packages/frontend/src/components/MkButton.vue
+++ b/packages/frontend/src/components/MkButton.vue
@@ -7,7 +7,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<button
v-if="!link"
ref="el" class="_button"
- :class="[$style.root, { [$style.inline]: inline, [$style.primary]: primary, [$style.gradate]: gradate, [$style.danger]: danger, [$style.rounded]: rounded, [$style.full]: full, [$style.small]: small, [$style.large]: large, [$style.transparent]: transparent, [$style.asLike]: asLike, [$style.iconOnly]: iconOnly, [$style.wait]: wait }]"
+ :class="[$style.root, { [$style.inline]: inline, [$style.primary]: primary, [$style.gradate]: gradate, [$style.danger]: danger, [$style.rounded]: rounded, [$style.full]: full, [$style.small]: small, [$style.large]: large, [$style.transparent]: transparent, [$style.asLike]: asLike, [$style.iconOnly]: iconOnly, [$style.wait]: wait, [$style.active]: active }]"
:type="type"
:name="name"
:value="value"
@@ -22,7 +22,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</button>
<MkA
v-else class="_button"
- :class="[$style.root, { [$style.inline]: inline, [$style.primary]: primary, [$style.gradate]: gradate, [$style.danger]: danger, [$style.rounded]: rounded, [$style.full]: full, [$style.small]: small, [$style.large]: large, [$style.transparent]: transparent, [$style.asLike]: asLike, [$style.iconOnly]: iconOnly, [$style.wait]: wait }]"
+ :class="[$style.root, { [$style.inline]: inline, [$style.primary]: primary, [$style.gradate]: gradate, [$style.danger]: danger, [$style.rounded]: rounded, [$style.full]: full, [$style.small]: small, [$style.large]: large, [$style.transparent]: transparent, [$style.asLike]: asLike, [$style.iconOnly]: iconOnly, [$style.wait]: wait, [$style.active]: active }]"
:to="to ?? '#'"
:behavior="linkBehavior"
@mousedown="onMousedown"
@@ -58,6 +58,7 @@ const props = defineProps<{
value?: string;
disabled?: boolean;
iconOnly?: boolean;
+ active?: boolean;
}>();
const emit = defineEmits<{
@@ -252,6 +253,10 @@ function onMousedown(evt: MouseEvent): void {
}
}
+ &.active {
+ color: var(--MI_THEME-accent) !important;
+ }
+
&:disabled {
opacity: 0.5;
}
diff --git a/packages/frontend/src/components/MkPagination.vue b/packages/frontend/src/components/MkPagination.vue
index d34646ba75..f069caeb44 100644
--- a/packages/frontend/src/components/MkPagination.vue
+++ b/packages/frontend/src/components/MkPagination.vue
@@ -6,10 +6,24 @@ SPDX-License-Identifier: AGPL-3.0-only
<template>
<component :is="prefer.s.enablePullToRefresh && pullToRefresh ? MkPullToRefresh : 'div'" :refresher="() => paginator.reload()" @contextmenu.prevent.stop="onContextmenu">
<div>
- <div v-if="props.withControl" :class="$style.control">
- <MkSelect v-model="order" :class="$style.order" :items="[{ label: i18n.ts._order.newest, value: 'newest' }, { label: i18n.ts._order.oldest, value: 'oldest' }]">
- </MkSelect>
- <MkButton iconOnly @click="paginator.reload()"><i class="ti ti-refresh"></i></MkButton>
+ <div v-if="props.withControl" :class="$style.controls">
+ <div :class="$style.control">
+ <MkSelect v-model="order" :class="$style.order" :items="[{ label: i18n.ts._order.newest, value: 'newest' }, { label: i18n.ts._order.oldest, value: 'oldest' }]">
+ <template #prefix><i class="ti ti-arrows-sort"></i></template>
+ </MkSelect>
+ <!-- TODO -->
+ <!-- <MkButton v-tooltip="i18n.ts.search" iconOnly transparent rounded @click="setSearchQuery"><i class="ti ti-search"></i></MkButton> -->
+ <MkButton v-tooltip="i18n.ts.dateAndTime" iconOnly transparent rounded :active="date != null" @click="date = date == null ? Date.now() : null"><i class="ti ti-calendar-clock"></i></MkButton>
+ <MkButton v-tooltip="i18n.ts.reload" iconOnly transparent rounded @click="paginator.reload()"><i class="ti ti-refresh"></i></MkButton>
+ </div>
+
+ <MkInput
+ v-if="date != null"
+ type="date"
+ :modelValue="formatDateTimeString(new Date(date), 'yyyy-MM-dd')"
+ @update:modelValue="date = new Date($event).getTime()"
+ >
+ </MkInput>
</div>
<!-- :css="prefer.s.animation" にしたいけどバグる(おそらくvueのバグ) https://github.com/misskey-dev/misskey/issues/16078 -->
@@ -59,7 +73,9 @@ import { prefer } from '@/preferences.js';
import { usePagination } from '@/composables/use-pagination.js';
import MkPullToRefresh from '@/components/MkPullToRefresh.vue';
import MkSelect from '@/components/MkSelect.vue';
+import MkInput from '@/components/MkInput.vue';
import * as os from '@/os.js';
+import { formatDateTimeString } from '@/utility/format-time-string.js';
type Paginator = ReturnType<typeof usePagination<T['endpoint']>>;
@@ -76,16 +92,18 @@ const props = withDefaults(defineProps<{
});
const order = ref<'newest' | 'oldest'>(props.pagination.order ?? 'newest');
+const date = ref<number | null>(null);
const paginator: Paginator = usePagination({
ctx: props.pagination,
});
-watch(order, (newOrder) => {
+watch([order, date], () => {
paginator.updateCtx({
...props.pagination,
- order: newOrder,
- initialDirection: newOrder === 'oldest' ? 'newer' : 'older',
+ order: order.value,
+ initialDirection: order.value === 'oldest' ? 'newer' : 'older',
+ initialDate: date.value,
});
}, { immediate: false });
@@ -123,15 +141,22 @@ defineExpose({
opacity: 0;
}
+.controls {
+ display: flex;
+ flex-direction: column;
+ gap: 8px;
+ margin-bottom: 10px;
+}
+
.control {
display: flex;
align-items: center;
- margin-bottom: 10px;
+ gap: 4px;
}
.order {
flex: 1;
- margin-right: 8px;
+ margin-right: 6px;
}
.more {
diff --git a/packages/frontend/src/composables/use-pagination.ts b/packages/frontend/src/composables/use-pagination.ts
index ed891c0b14..4411f163af 100644
--- a/packages/frontend/src/composables/use-pagination.ts
+++ b/packages/frontend/src/composables/use-pagination.ts
@@ -34,6 +34,7 @@ export type PagingCtx<E extends keyof Misskey.Endpoints = keyof Misskey.Endpoint
offsetMode?: boolean;
initialId?: MisskeyEntity['id'];
+ initialDate?: number | null;
initialDirection?: 'newer' | 'older';
// 配列内の要素をどのような順序で並べるか
@@ -89,14 +90,18 @@ export function usePagination<Endpoint extends keyof Misskey.Endpoints, T extend
...params,
limit: props.ctx.limit ?? FIRST_FETCH_LIMIT,
allowPartial: true,
- ...(props.ctx.initialDirection === 'newer' ? {
- sinceId: props.ctx.initialId ?? '0',
- } : props.ctx.initialId && props.ctx.initialDirection === 'older' ? {
+ ...((props.ctx.initialId == null && props.ctx.initialDate == null) && props.ctx.initialDirection === 'newer' ? {
+ sinceId: '0',
+ } : props.ctx.initialDirection === 'newer' ? {
+ sinceId: props.ctx.initialId,
+ sinceDate: props.ctx.initialDate,
+ } : (props.ctx.initialId || props.ctx.initialDate) && props.ctx.initialDirection === 'older' ? {
untilId: props.ctx.initialId,
+ untilDate: props.ctx.initialDate,
} : {}),
}).then(res => {
// 逆順で返ってくるので
- if (props.ctx.initialId && props.ctx.initialDirection === 'newer') {
+ if ((props.ctx.initialId || props.ctx.initialDate) && props.ctx.initialDirection === 'newer') {
res.reverse();
}