From 7ffe2181a919d0a9d39058047de511c584c24f5d Mon Sep 17 00:00:00 2001 From: Johann150 Date: Sat, 19 Nov 2022 17:33:27 +0100 Subject: [PATCH 1/5] server: use host parameter in note search without elasticsearch Changelog: Fixed --- packages/backend/src/server/api/endpoints/notes/search.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/backend/src/server/api/endpoints/notes/search.ts b/packages/backend/src/server/api/endpoints/notes/search.ts index 8d8b21238..e75fe0ef6 100644 --- a/packages/backend/src/server/api/endpoints/notes/search.ts +++ b/packages/backend/src/server/api/endpoints/notes/search.ts @@ -50,6 +50,8 @@ export default define(meta, paramDef, async (ps, me) => { if (ps.userId) { query.andWhere('note.userId = :userId', { userId: ps.userId }); + } else if (ps.host) { + query.andWhere('note.userHost = :host', { host: ps.host }); } else if (ps.channelId) { query.andWhere('note.channelId = :channelId', { channelId: ps.channelId }); } From d86f826458e54d1af3e5ea47da09ed0bb5687d20 Mon Sep 17 00:00:00 2001 From: Johann150 Date: Sat, 19 Nov 2022 19:21:06 +0100 Subject: [PATCH 2/5] client: remove scripts/search --- packages/client/src/init.ts | 6 ++- packages/client/src/menu.ts | 3 +- packages/client/src/scripts/search.ts | 63 ----------------------- packages/client/src/ui/visitor/b.vue | 5 +- packages/client/src/ui/visitor/header.vue | 3 +- 5 files changed, 9 insertions(+), 71 deletions(-) delete mode 100644 packages/client/src/scripts/search.ts diff --git a/packages/client/src/init.ts b/packages/client/src/init.ts index d428c9ceb..692617abd 100644 --- a/packages/client/src/init.ts +++ b/packages/client/src/init.ts @@ -30,8 +30,8 @@ import * as sound from '@/scripts/sound'; import { $i, refreshAccount, login, updateAccount, signout } from '@/account'; import { defaultStore, ColdDeviceStorage } from '@/store'; import { fetchInstance, instance } from '@/instance'; +import { mainRouter } from '@/router'; import { makeHotkey } from '@/scripts/hotkey'; -import { search } from '@/scripts/search'; import { deviceKind } from '@/scripts/device-kind'; import { initializeSw } from '@/scripts/initialize-sw'; import { reloadChannel } from '@/scripts/unison-reload'; @@ -332,7 +332,9 @@ import { getAccountFromId } from '@/scripts/get-account-from-id'; 'd': (): void => { defaultStore.set('darkMode', !defaultStore.state.darkMode); }, - 's': search, + 's': (): void => { + mainRouter.push('/search'); + }, }; if ($i) { diff --git a/packages/client/src/menu.ts b/packages/client/src/menu.ts index dbe85fe4f..b730fdd8e 100644 --- a/packages/client/src/menu.ts +++ b/packages/client/src/menu.ts @@ -1,7 +1,6 @@ import { computed, ref, reactive } from 'vue'; import { $i } from '@/account'; import { mainRouter } from '@/router'; -import { search } from '@/scripts/search'; import * as os from '@/os'; import { i18n } from '@/i18n'; import { ui } from '@/config'; @@ -49,7 +48,7 @@ export const menuDef = reactive({ search: { title: 'search', icon: 'fas fa-search', - action: () => search(), + to: '/search', }, lists: { title: 'lists', diff --git a/packages/client/src/scripts/search.ts b/packages/client/src/scripts/search.ts deleted file mode 100644 index 64914d3d6..000000000 --- a/packages/client/src/scripts/search.ts +++ /dev/null @@ -1,63 +0,0 @@ -import * as os from '@/os'; -import { i18n } from '@/i18n'; -import { mainRouter } from '@/router'; - -export async function search() { - const { canceled, result: query } = await os.inputText({ - title: i18n.ts.search, - }); - if (canceled || query == null || query === '') return; - - const q = query.trim(); - - if (q.startsWith('@') && !q.includes(' ')) { - mainRouter.push(`/${q}`); - return; - } - - if (q.startsWith('#')) { - mainRouter.push(`/tags/${encodeURIComponent(q.substr(1))}`); - return; - } - - // like 2018/03/12 - if (/^[0-9]{4}\/[0-9]{2}\/[0-9]{2}/.test(q.replace(/-/g, '/'))) { - const date = new Date(q.replace(/-/g, '/')); - - // 日付しか指定されてない場合、例えば 2018/03/12 ならユーザーは - // 2018/03/12 のコンテンツを「含む」結果になることを期待するはずなので - // 23時間59分進める(そのままだと 2018/03/12 00:00:00 「まで」の - // 結果になってしまい、2018/03/12 のコンテンツは含まれない) - if (q.replace(/-/g, '/').match(/^[0-9]{4}\/[0-9]{2}\/[0-9]{2}$/)) { - date.setHours(23, 59, 59, 999); - } - - // TODO - //v.$root.$emit('warp', date); - os.alert({ - icon: 'fas fa-history', - iconOnly: true, autoClose: true, - }); - return; - } - - if (q.startsWith('https://')) { - const promise = os.api('ap/show', { - uri: q, - }); - - os.promiseDialog(promise, null, null, i18n.ts.fetchingAsApObject); - - const res = await promise; - - if (res.type === 'User') { - mainRouter.push(`/@${res.object.username}@${res.object.host}`); - } else if (res.type === 'Note') { - mainRouter.push(`/notes/${res.object.id}`); - } - - return; - } - - mainRouter.push(`/search?q=${encodeURIComponent(q)}`); -} diff --git a/packages/client/src/ui/visitor/b.vue b/packages/client/src/ui/visitor/b.vue index 7f8446bc2..e330e5a70 100644 --- a/packages/client/src/ui/visitor/b.vue +++ b/packages/client/src/ui/visitor/b.vue @@ -50,7 +50,6 @@ import { ComputedRef, onMounted, provide } from 'vue'; import XHeader from './header.vue'; import XKanban from './kanban.vue'; import { host, instanceName } from '@/config'; -import { search } from '@/scripts/search'; import * as os from '@/os'; import MkPagination from '@/components/ui/pagination.vue'; import XSigninDialog from '@/components/signin-dialog.vue'; @@ -87,7 +86,9 @@ const keymap = $computed(() => { if (ColdDeviceStorage.get('syncDeviceDarkMode')) return; defaultStore.set('darkMode', !defaultStore.state.darkMode); }, - 's': search, + 's': () => { + mainRouter.push('/search'); + }, }; }); diff --git a/packages/client/src/ui/visitor/header.vue b/packages/client/src/ui/visitor/header.vue index 71d393284..dc364e16e 100644 --- a/packages/client/src/ui/visitor/header.vue +++ b/packages/client/src/ui/visitor/header.vue @@ -18,7 +18,7 @@
- + {{ i18n.ts.search }}
@@ -46,7 +46,6 @@ import { onMounted, ref, Ref } from 'vue'; import XSigninDialog from '@/components/signin-dialog.vue'; import XSignupDialog from '@/components/signup-dialog.vue'; import * as os from '@/os'; -import { search } from '@/scripts/search'; import { i18n } from '@/i18n'; defineProps<{ From a7f3133f89c7a6c00ee304ff1838b6d26e14b24d Mon Sep 17 00:00:00 2001 From: Johann150 Date: Sat, 19 Nov 2022 19:28:19 +0100 Subject: [PATCH 3/5] client: search page for notes and users This replaces the previous search box and allows for more narrowed down searches. Changelog: Added --- locales/en-US.yml | 1 - packages/client/src/pages/search.vue | 213 +++++++++++++++++++++++++-- 2 files changed, 197 insertions(+), 17 deletions(-) diff --git a/locales/en-US.yml b/locales/en-US.yml index c8cca2f4f..e1a01856a 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -167,7 +167,6 @@ general: "General" wallpaper: "Wallpaper" setWallpaper: "Set wallpaper" removeWallpaper: "Remove wallpaper" -searchWith: "Search: {q}" youHaveNoLists: "You don't have any lists" followConfirm: "Are you sure that you want to follow {name}?" proxyAccount: "Proxy account" diff --git a/packages/client/src/pages/search.vue b/packages/client/src/pages/search.vue index 1dcf18161..b5bf9fdb9 100644 --- a/packages/client/src/pages/search.vue +++ b/packages/client/src/pages/search.vue @@ -1,34 +1,215 @@ + + From 33e09b990145b3917e195e6dfe76bcbd9049862f Mon Sep 17 00:00:00 2001 From: Johann150 Date: Sat, 19 Nov 2022 19:34:25 +0100 Subject: [PATCH 4/5] client: remove user search from explore page User search is now located on the general search page. Also cleaned up other unused code. Changelog: Removed --- packages/client/src/pages/explore.vue | 43 +-------------------------- 1 file changed, 1 insertion(+), 42 deletions(-) diff --git a/packages/client/src/pages/explore.vue b/packages/client/src/pages/explore.vue index d27c32885..35a5c75c4 100644 --- a/packages/client/src/pages/explore.vue +++ b/packages/client/src/pages/explore.vue @@ -11,57 +11,19 @@
-
-
- - - - - - - - - -
- - -