Skip to content

Commit

Permalink
frontend: ハッシュタグTLをリアルタイムに更新 (yojo-art#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
kozakura913 authored Jul 3, 2024
2 parents 24a2334 + f3dfb0b commit deb5a72
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG_yojo.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

### Client
- feat: 未ログイン時サーバーで指定されている場合、マスコット画像が表示されます
- enhance: ハッシュタグTLをリアルタイムに更新

### Server
- fix: リモートユーザーにはファイルサイズ制限を適用しない
Expand Down
2 changes: 1 addition & 1 deletion packages/cherrypick-js/etc/cherrypick-js.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ export type Channels = {
};
hashtag: {
params: {
q?: string;
q?: string[][];
};
events: {
note: (payload: Note) => void;
Expand Down
2 changes: 1 addition & 1 deletion packages/cherrypick-js/src/streaming.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export type Channels = {
};
hashtag: {
params: {
q?: string;
q?: string[][];
};
events: {
note: (payload: Note) => void;
Expand Down
14 changes: 14 additions & 0 deletions packages/frontend/src/pages/tag.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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<{
Expand All @@ -42,6 +43,8 @@ const pagination = {
};
const notes = ref<InstanceType<typeof MkNotes>>();

const stream = useStream();

async function post() {
defaultStore.set('postFormHashtags', props.tag);
defaultStore.set('postFormWithHashtags', true);
Expand All @@ -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();
</script>

<style lang="scss" module>
Expand Down

0 comments on commit deb5a72

Please sign in to comment.