Compare commits
No commits in common. "f386b8d8033172d9974a7563c58dcc80b52cbb40" and "aaf93607bc05cf8cdc1f29a8e9902a3601824565" have entirely different histories.
f386b8d803
...
aaf93607bc
|
@ -193,7 +193,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, inject, onMounted, ref, useTemplateRef, provide } from 'vue';
|
import { computed, inject, onMounted, ref, useTemplateRef, watch, provide, shallowRef, reactive } from 'vue';
|
||||||
import * as mfm from 'mfm-js';
|
import * as mfm from 'mfm-js';
|
||||||
import * as Misskey from 'misskey-js';
|
import * as Misskey from 'misskey-js';
|
||||||
import { isLink } from '@@/js/is-link.js';
|
import { isLink } from '@@/js/is-link.js';
|
||||||
|
@ -228,6 +228,7 @@ import { $i } from '@/i.js';
|
||||||
import { i18n } from '@/i18n.js';
|
import { i18n } from '@/i18n.js';
|
||||||
import { getAbuseNoteMenu, getCopyNoteLinkMenu, getNoteClipMenu, getNoteMenu, getRenoteMenu } from '@/utility/get-note-menu.js';
|
import { getAbuseNoteMenu, getCopyNoteLinkMenu, getNoteClipMenu, getNoteMenu, getRenoteMenu } from '@/utility/get-note-menu.js';
|
||||||
import { noteEvents, useNoteCapture } from '@/composables/use-note-capture.js';
|
import { noteEvents, useNoteCapture } from '@/composables/use-note-capture.js';
|
||||||
|
import type { ReactiveNoteData } from '@/composables/use-note-capture.js';
|
||||||
import { deepClone } from '@/utility/clone.js';
|
import { deepClone } from '@/utility/clone.js';
|
||||||
import { useTooltip } from '@/composables/use-tooltip.js';
|
import { useTooltip } from '@/composables/use-tooltip.js';
|
||||||
import { claimAchievement } from '@/utility/achievements.js';
|
import { claimAchievement } from '@/utility/achievements.js';
|
||||||
|
@ -283,10 +284,12 @@ if (noteViewInterruptors.length > 0) {
|
||||||
|
|
||||||
const isRenote = Misskey.note.isPureRenote(note);
|
const isRenote = Misskey.note.isPureRenote(note);
|
||||||
const appearNote = getAppearNote(note);
|
const appearNote = getAppearNote(note);
|
||||||
const { $note: $appearNote, subscribe: subscribeManuallyToNoteCapture } = useNoteCapture({
|
const $appearNote = reactive<ReactiveNoteData>({
|
||||||
note: appearNote,
|
reactions: appearNote.reactions,
|
||||||
parentNote: note,
|
reactionCount: appearNote.reactionCount,
|
||||||
mock: props.mock,
|
reactionEmojis: appearNote.reactionEmojis,
|
||||||
|
myReaction: appearNote.myReaction,
|
||||||
|
pollChoices: appearNote.poll?.choices ?? [],
|
||||||
});
|
});
|
||||||
|
|
||||||
const rootEl = useTemplateRef('rootEl');
|
const rootEl = useTemplateRef('rootEl');
|
||||||
|
@ -408,6 +411,17 @@ provide(DI.mfmEmojiReactCallback, (reaction) => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let subscribeManuallyToNoteCapture: () => void = () => { };
|
||||||
|
|
||||||
|
if (!props.mock) {
|
||||||
|
const { subscribe } = useNoteCapture({
|
||||||
|
note: appearNote,
|
||||||
|
parentNote: note,
|
||||||
|
$note: $appearNote,
|
||||||
|
});
|
||||||
|
subscribeManuallyToNoteCapture = subscribe;
|
||||||
|
}
|
||||||
|
|
||||||
if (!props.mock) {
|
if (!props.mock) {
|
||||||
useTooltip(renoteButton, async (showing) => {
|
useTooltip(renoteButton, async (showing) => {
|
||||||
const renotes = await misskeyApi('notes/renotes', {
|
const renotes = await misskeyApi('notes/renotes', {
|
||||||
|
|
|
@ -228,7 +228,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, inject, onMounted, provide, ref, useTemplateRef } from 'vue';
|
import { computed, inject, onMounted, provide, reactive, ref, useTemplateRef } from 'vue';
|
||||||
import * as mfm from 'mfm-js';
|
import * as mfm from 'mfm-js';
|
||||||
import * as Misskey from 'misskey-js';
|
import * as Misskey from 'misskey-js';
|
||||||
import { isLink } from '@@/js/is-link.js';
|
import { isLink } from '@@/js/is-link.js';
|
||||||
|
@ -259,6 +259,7 @@ import { $i } from '@/i.js';
|
||||||
import { i18n } from '@/i18n.js';
|
import { i18n } from '@/i18n.js';
|
||||||
import { getNoteClipMenu, getNoteMenu, getRenoteMenu } from '@/utility/get-note-menu.js';
|
import { getNoteClipMenu, getNoteMenu, getRenoteMenu } from '@/utility/get-note-menu.js';
|
||||||
import { noteEvents, useNoteCapture } from '@/composables/use-note-capture.js';
|
import { noteEvents, useNoteCapture } from '@/composables/use-note-capture.js';
|
||||||
|
import type { ReactiveNoteData } from '@/composables/use-note-capture.js';
|
||||||
import { deepClone } from '@/utility/clone.js';
|
import { deepClone } from '@/utility/clone.js';
|
||||||
import { useTooltip } from '@/composables/use-tooltip.js';
|
import { useTooltip } from '@/composables/use-tooltip.js';
|
||||||
import { claimAchievement } from '@/utility/achievements.js';
|
import { claimAchievement } from '@/utility/achievements.js';
|
||||||
|
@ -304,9 +305,12 @@ if (noteViewInterruptors.length > 0) {
|
||||||
|
|
||||||
const isRenote = Misskey.note.isPureRenote(note);
|
const isRenote = Misskey.note.isPureRenote(note);
|
||||||
const appearNote = getAppearNote(note);
|
const appearNote = getAppearNote(note);
|
||||||
const { $note: $appearNote, subscribe: subscribeManuallyToNoteCapture } = useNoteCapture({
|
const $appearNote = reactive<ReactiveNoteData>({
|
||||||
note: appearNote,
|
reactions: appearNote.reactions,
|
||||||
parentNote: note,
|
reactionCount: appearNote.reactionCount,
|
||||||
|
reactionEmojis: appearNote.reactionEmojis,
|
||||||
|
myReaction: appearNote.myReaction,
|
||||||
|
pollChoices: appearNote.poll?.choices ?? [],
|
||||||
});
|
});
|
||||||
|
|
||||||
const rootEl = useTemplateRef('rootEl');
|
const rootEl = useTemplateRef('rootEl');
|
||||||
|
@ -394,6 +398,12 @@ const reactionsPagination = computed(() => ({
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
const { subscribe: subscribeManuallyToNoteCapture } = useNoteCapture({
|
||||||
|
note: appearNote,
|
||||||
|
parentNote: note,
|
||||||
|
$note: $appearNote,
|
||||||
|
});
|
||||||
|
|
||||||
useTooltip(renoteButton, async (showing) => {
|
useTooltip(renoteButton, async (showing) => {
|
||||||
const renotes = await misskeyApi('notes/renotes', {
|
const renotes = await misskeyApi('notes/renotes', {
|
||||||
noteId: appearNote.id,
|
noteId: appearNote.id,
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { onUnmounted, reactive } from 'vue';
|
import { onUnmounted } from 'vue';
|
||||||
import * as Misskey from 'misskey-js';
|
import * as Misskey from 'misskey-js';
|
||||||
import { EventEmitter } from 'eventemitter3';
|
import { EventEmitter } from 'eventemitter3';
|
||||||
import type { Reactive } from 'vue';
|
import type { Reactive } from 'vue';
|
||||||
|
@ -188,18 +188,17 @@ export type ReactiveNoteData = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export function useNoteCapture(props: {
|
export function useNoteCapture(props: {
|
||||||
note: Misskey.entities.Note;
|
note: Pick<Misskey.entities.Note, 'id' | 'createdAt'>;
|
||||||
parentNote: Misskey.entities.Note | null;
|
parentNote: Misskey.entities.Note | null;
|
||||||
mock?: boolean;
|
|
||||||
}): {
|
|
||||||
$note: Reactive<ReactiveNoteData>;
|
$note: Reactive<ReactiveNoteData>;
|
||||||
|
}): {
|
||||||
subscribe: () => void;
|
subscribe: () => void;
|
||||||
} {
|
} {
|
||||||
const { note, parentNote, mock } = props;
|
const { note, parentNote, $note } = props;
|
||||||
|
|
||||||
const $note = reactive<ReactiveNoteData>({
|
// Normalize reactions
|
||||||
reactions: Object.entries(note.reactions).reduce((acc, [name, count]) => {
|
if (Object.keys($note.reactions).length > 0) {
|
||||||
// Normalize reactions
|
$note.reactions = Object.entries($note.reactions).reduce((acc, [name, count]) => {
|
||||||
const normalizedName = name.replace(/^:(\w+):$/, ':$1@.:');
|
const normalizedName = name.replace(/^:(\w+):$/, ':$1@.:');
|
||||||
if (acc[normalizedName] == null) {
|
if (acc[normalizedName] == null) {
|
||||||
acc[normalizedName] = count;
|
acc[normalizedName] = count;
|
||||||
|
@ -207,12 +206,8 @@ export function useNoteCapture(props: {
|
||||||
acc[normalizedName] += count;
|
acc[normalizedName] += count;
|
||||||
}
|
}
|
||||||
return acc;
|
return acc;
|
||||||
}, {} as Misskey.entities.Note['reactions']),
|
}, {} as Misskey.entities.Note['reactions']);
|
||||||
reactionCount: note.reactionCount,
|
}
|
||||||
reactionEmojis: note.reactionEmojis,
|
|
||||||
myReaction: note.myReaction,
|
|
||||||
pollChoices: note.poll?.choices ?? [],
|
|
||||||
});
|
|
||||||
|
|
||||||
noteEvents.on(`reacted:${note.id}`, onReacted);
|
noteEvents.on(`reacted:${note.id}`, onReacted);
|
||||||
noteEvents.on(`unreacted:${note.id}`, onUnreacted);
|
noteEvents.on(`unreacted:${note.id}`, onUnreacted);
|
||||||
|
@ -277,20 +272,10 @@ export function useNoteCapture(props: {
|
||||||
}
|
}
|
||||||
|
|
||||||
function subscribe() {
|
function subscribe() {
|
||||||
if (mock) {
|
|
||||||
// モックモードでは購読しない
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($i && store.s.realtimeMode) {
|
if ($i && store.s.realtimeMode) {
|
||||||
realtimeSubscribe({
|
realtimeSubscribe(props);
|
||||||
note,
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
pollingSubscribe({
|
pollingSubscribe(props);
|
||||||
note,
|
|
||||||
$note,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -307,7 +292,6 @@ export function useNoteCapture(props: {
|
||||||
if ((Date.now() - new Date(note.createdAt).getTime()) > 1000 * 60 * 5) { // 5min
|
if ((Date.now() - new Date(note.createdAt).getTime()) > 1000 * 60 * 5) { // 5min
|
||||||
// リノートで表示されているノートでもないし、投稿からある程度経過しているので自動で購読しない
|
// リノートで表示されているノートでもないし、投稿からある程度経過しているので自動で購読しない
|
||||||
return {
|
return {
|
||||||
$note,
|
|
||||||
subscribe: () => {
|
subscribe: () => {
|
||||||
subscribe();
|
subscribe();
|
||||||
},
|
},
|
||||||
|
@ -317,7 +301,6 @@ export function useNoteCapture(props: {
|
||||||
if ((Date.now() - new Date(parentNote.createdAt).getTime()) > 1000 * 60 * 5) { // 5min
|
if ((Date.now() - new Date(parentNote.createdAt).getTime()) > 1000 * 60 * 5) { // 5min
|
||||||
// リノートで表示されているノートだが、リノートされてからある程度経過しているので自動で購読しない
|
// リノートで表示されているノートだが、リノートされてからある程度経過しているので自動で購読しない
|
||||||
return {
|
return {
|
||||||
$note,
|
|
||||||
subscribe: () => {
|
subscribe: () => {
|
||||||
subscribe();
|
subscribe();
|
||||||
},
|
},
|
||||||
|
@ -328,7 +311,6 @@ export function useNoteCapture(props: {
|
||||||
subscribe();
|
subscribe();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
$note,
|
|
||||||
subscribe: () => {
|
subscribe: () => {
|
||||||
// すでに購読しているので何もしない
|
// すでに購読しているので何もしない
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue