Add stuff talked about on MR

This commit is contained in:
KevinWh0 2024-07-16 22:06:38 +02:00
parent b5a69c3aea
commit f97417cfca
3 changed files with 9 additions and 9 deletions

View File

@ -9,6 +9,7 @@ import type { DriveFilesRepository } from '@/models/_.js';
import { QueryService } from '@/core/QueryService.js';
import { DriveFileEntityService } from '@/core/entities/DriveFileEntityService.js';
import { DI } from '@/di-symbols.js';
import { sqlLikeEscape } from '@/misc/sql-like-escape.js';
export const meta = {
tags: ['drive'],
@ -62,7 +63,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
}
if (ps.searchQuery.length > 0) {
query.andWhere('file.name ILIKE :searchQuery OR file.comment ILIKE :searchQuery', { searchQuery: `%${ps.searchQuery}%` });
query.andWhere('file.name ILIKE :searchQuery OR file.comment ILIKE :searchQuery', { searchQuery: `%${sqlLikeEscape(ps.searchQuery)}%` });
}
if (ps.type) {

View File

@ -9,6 +9,7 @@ import type { DriveFoldersRepository } from '@/models/_.js';
import { QueryService } from '@/core/QueryService.js';
import { DriveFolderEntityService } from '@/core/entities/DriveFolderEntityService.js';
import { DI } from '@/di-symbols.js';
import { sqlLikeEscape } from '@/misc/sql-like-escape.js';
export const meta = {
tags: ['drive'],
@ -60,7 +61,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
}
if (ps.searchQuery.length > 0) {
query.andWhere('folder.name ILIKE :searchQuery', { searchQuery: `%${ps.searchQuery}%` });
query.andWhere('folder.name ILIKE :searchQuery', { searchQuery: `%${sqlLikeEscape(ps.searchQuery)}%` });
}
const folders = await query.limit(ps.limit).getMany();

View File

@ -32,7 +32,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</div>
<div :class="$style.navMenu">
<!-- "Search drive via alt text or file names" -->
<MkInput v-model="searchQuery" :large="true" :autofocus="true" type="search" :placeholder="i18n.ts.driveSearchbarPlaceholder" @enter="search">
<MkInput v-model="searchQuery" :large="true" :autofocus="true" type="search" :placeholder="i18n.ts.driveSearchbarPlaceholder" @enter="fetch">
<template #prefix><i class="ph-magnifying-glass ph-bold ph-lg"></i></template>
</MkInput>
@ -162,10 +162,6 @@ const isDragSource = ref(false);
const fetching = ref(true);
async function search() {
fetch();
}
const ilFilesObserver = new IntersectionObserver(
(entries) => entries.some((entry) => entry.isIntersecting) && !fetching.value && moreFiles.value && fetchMoreFiles(),
);
@ -594,6 +590,7 @@ function fetchMoreFolders() {
type: props.type,
untilId: folders.value.at(-1)?.id,
limit: max + 1,
searchQuery: searchQuery.value.toString().trim(),
}).then(folders => {
if (folders.length === max + 1) {
moreFolders.value = true;
@ -617,6 +614,7 @@ function fetchMoreFiles() {
type: props.type,
untilId: files.value.at(-1)?.id,
limit: max + 1,
searchQuery: searchQuery.value.toString().trim(),
}).then(files => {
if (files.length === max + 1) {
moreFiles.value = true;