From 87058142a9c7d33a2f43ddbade231b26d99a9771 Mon Sep 17 00:00:00 2001 From: kozakura913 <98575220+kozakura913@users.noreply.github.com> Date: Wed, 3 Jul 2024 19:10:56 +0900 Subject: [PATCH] =?UTF-8?q?frontend:=20=E3=83=8F=E3=83=83=E3=82=B7?= =?UTF-8?q?=E3=83=A5=E3=82=BF=E3=82=B0TL=E3=82=92=E3=83=AA=E3=82=A2?= =?UTF-8?q?=E3=83=AB=E3=82=BF=E3=82=A4=E3=83=A0=E3=81=AB=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/cherrypick-js/etc/cherrypick-js.api.md | 2 +- packages/cherrypick-js/src/streaming.types.ts | 2 +- packages/frontend/src/pages/tag.vue | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/packages/cherrypick-js/etc/cherrypick-js.api.md b/packages/cherrypick-js/etc/cherrypick-js.api.md index 3ccf660572..23429f188e 100644 --- a/packages/cherrypick-js/etc/cherrypick-js.api.md +++ b/packages/cherrypick-js/etc/cherrypick-js.api.md @@ -723,7 +723,7 @@ export type Channels = { }; hashtag: { params: { - q?: string; + q?: string[][]; }; events: { note: (payload: Note) => void; diff --git a/packages/cherrypick-js/src/streaming.types.ts b/packages/cherrypick-js/src/streaming.types.ts index 6b997cad44..7df8dcd8c8 100644 --- a/packages/cherrypick-js/src/streaming.types.ts +++ b/packages/cherrypick-js/src/streaming.types.ts @@ -142,7 +142,7 @@ export type Channels = { }; hashtag: { params: { - q?: string; + q?: string[][]; }; events: { note: (payload: Note) => void; diff --git a/packages/frontend/src/pages/tag.vue b/packages/frontend/src/pages/tag.vue index 9b77392872..be40075be8 100644 --- a/packages/frontend/src/pages/tag.vue +++ b/packages/frontend/src/pages/tag.vue @@ -27,6 +27,7 @@ import { definePageMetadata } from '@/scripts/page-metadata.js'; import { i18n } from '@/i18n.js'; import { $i } from '@/account.js'; import { defaultStore } from '@/store.js'; +import { useStream } from '@/stream.js'; import * as os from '@/os.js'; const props = defineProps<{ @@ -42,6 +43,8 @@ const pagination = { }; const notes = ref>(); +const stream = useStream(); + async function post() { defaultStore.set('postFormHashtags', props.tag); defaultStore.set('postFormWithHashtags', true); @@ -59,6 +62,17 @@ definePageMetadata(() => ({ title: props.tag, icon: 'ti ti-hash', })); + +function openStream() { + const connection = stream.useChannel('hashtag', { + q: [[props.tag]], + }); + connection.on('note', note => { + notes.value?.pagingComponent?.prepend(note); + }); +} + +openStream();