Skip to content

Commit b5454cb

Browse files
fix(frontend): 登録日によるソートの場合はpaginator側のソートを使用するように (#17048)
* fix(frontend): 登録日によるソートの場合はpaginator側のソートを使用するように * Update Changelog * fix lint * refactor
1 parent 8577f10 commit b5454cb

2 files changed

Lines changed: 19 additions & 9 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- Enhance: ウィジェットの表示設定をプレビューを見ながら行えるように
1414
- Enhance: ウィジェットの設定項目のラベルの多言語対応
1515
- Fix: ドライブクリーナーでファイルを削除しても画面に反映されない問題を修正 #16061
16+
- Fix: ドライブのソートが「登録日(昇順)」の場合に正しく動作しない問題を修正
1617

1718
### Server
1819
- Enhance: OAuthのクライアント情報取得(Client Information Discovery)において、IndieWeb Living Standard 11 July 2024で定義されているJSONドキュメント形式に対応しました

packages/frontend/src/components/MkDrive.vue

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,12 @@ SPDX-License-Identifier: AGPL-3.0-only
133133
</TransitionGroup>
134134

135135
<MkButton
136-
v-show="filesPaginator.canFetchOlder.value"
137-
v-appear="shouldEnableInfiniteScroll ? filesPaginator.fetchOlder : null"
136+
v-show="canFetchFiles"
137+
v-appear="shouldEnableInfiniteScroll ? fetchMoreFiles : null"
138138
:class="$style.loadMore"
139139
primary
140140
rounded
141-
@click="filesPaginator.fetchOlder()"
141+
@click="fetchMoreFiles"
142142
>{{ i18n.ts.loadMore }}</MkButton>
143143

144144
<div v-if="filesPaginator.items.value.length == 0 && foldersPaginator.items.value.length == 0 && !fetching" :class="$style.empty">
@@ -238,10 +238,9 @@ const filesPaginator = markRaw(new Paginator('drive/files', {
238238
params: () => ({ // 自動でリロードしたくないためcomputedParamsは使わない
239239
folderId: folder.value ? folder.value.id : null,
240240
type: props.type,
241-
sort: sortModeSelect.value,
241+
sort: ['-createdAt', '+createdAt'].includes(sortModeSelect.value) ? null : sortModeSelect.value,
242242
}),
243243
}));
244-
245244
const foldersPaginator = markRaw(new Paginator('drive/folders', {
246245
limit: 30,
247246
canFetchDetection: 'limit',
@@ -250,6 +249,16 @@ const foldersPaginator = markRaw(new Paginator('drive/folders', {
250249
}),
251250
}));
252251
252+
const canFetchFiles = computed(() => !fetching.value && (filesPaginator.order.value === 'oldest' ? filesPaginator.canFetchNewer.value : filesPaginator.canFetchOlder.value));
253+
254+
async function fetchMoreFiles() {
255+
if (filesPaginator.order.value === 'oldest') {
256+
filesPaginator.fetchNewer();
257+
} else {
258+
filesPaginator.fetchOlder();
259+
}
260+
}
261+
253262
const filesTimeline = makeDateGroupedTimelineComputedRef(filesPaginator.items, 'month');
254263
const shouldBeGroupedByDate = computed(() => ['+createdAt', '-createdAt'].includes(sortModeSelect.value));
255264
@@ -260,10 +269,10 @@ watch(sortModeSelect, () => {
260269
261270
async function initialize() {
262271
fetching.value = true;
263-
await Promise.all([
264-
foldersPaginator.init(),
265-
filesPaginator.init(),
266-
]);
272+
await foldersPaginator.reload();
273+
filesPaginator.initialDirection = sortModeSelect.value === '-createdAt' ? 'newer' : 'older';
274+
filesPaginator.order.value = sortModeSelect.value === '-createdAt' ? 'oldest' : 'newest';
275+
await filesPaginator.reload();
267276
fetching.value = false;
268277
}
269278

0 commit comments

Comments
 (0)