Fix: なんかReplyがおかしいの

This commit is contained in:
mattyatea 2023-10-20 11:21:32 +09:00
parent d421670b54
commit 7bd7fe996c
6 changed files with 170 additions and 222 deletions

View File

@ -87,16 +87,6 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
if (ps.withFiles) { if (ps.withFiles) {
query.andWhere('note.fileIds != \'{}\''); query.andWhere('note.fileIds != \'{}\'');
} }
if (ps.withRenotes === false) {
query.andWhere(new Brackets(qb => {
qb.orWhere('note.renoteId IS NULL');
qb.orWhere(new Brackets(qb => {
qb.orWhere('note.text IS NOT NULL');
qb.orWhere('note.fileIds != \'{}\'');
}));
}));
}
//#endregion //#endregion
const timeline = await query.limit(ps.limit).getMany(); const timeline = await query.limit(ps.limit).getMany();

View File

@ -18,9 +18,8 @@ class GlobalTimelineChannel extends Channel {
public readonly chName = 'globalTimeline'; public readonly chName = 'globalTimeline';
public static shouldShare = false; public static shouldShare = false;
public static requireCredential = false; public static requireCredential = false;
private withReplies: boolean;
private withFiles: boolean;
private withRenotes: boolean; private withRenotes: boolean;
private withFiles: boolean;
constructor( constructor(
private metaService: MetaService, private metaService: MetaService,
@ -39,7 +38,6 @@ class GlobalTimelineChannel extends Channel {
const policies = await this.roleService.getUserPolicies(this.user ? this.user.id : null); const policies = await this.roleService.getUserPolicies(this.user ? this.user.id : null);
if (!policies.gtlAvailable) return; if (!policies.gtlAvailable) return;
this.withReplies = params.withReplies ?? false;
this.withRenotes = params.withRenotes ?? true; this.withRenotes = params.withRenotes ?? true;
this.withFiles = params.withFiles ?? false; this.withFiles = params.withFiles ?? false;
@ -49,25 +47,11 @@ class GlobalTimelineChannel extends Channel {
@bindThis @bindThis
private async onNote(note: Packed<'Note'>) { private async onNote(note: Packed<'Note'>) {
if (this.withFiles && (note.fileIds == null || note.fileIds.length === 0)) return;
if (note.visibility !== 'public') return; if (note.visibility !== 'public') return;
if (note.channelId != null) return; if (note.channelId != null) return;
// ファイルを含まない投稿は除外
if (this.withFiles && (note.files === undefined || note.files.length === 0)) return;
// リプライなら再pack
if (note.replyId != null) {
note.reply = await this.noteEntityService.pack(note.replyId, this.user, {
detail: true,
});
}
// Renoteなら再pack
if (note.renoteId != null) {
note.renote = await this.noteEntityService.pack(note.renoteId, this.user, {
detail: true,
});
}
// 関係ない返信は除外 // 関係ない返信は除外
if (note.reply && !this.following[note.userId]?.withReplies) { if (note.reply && !this.following[note.userId]?.withReplies) {
const reply = note.reply; const reply = note.reply;

View File

@ -16,9 +16,8 @@ class HomeTimelineChannel extends Channel {
public readonly chName = 'homeTimeline'; public readonly chName = 'homeTimeline';
public static shouldShare = false; public static shouldShare = false;
public static requireCredential = true; public static requireCredential = true;
private withReplies: boolean;
private withFiles: boolean;
private withRenotes: boolean; private withRenotes: boolean;
private withFiles: boolean;
constructor( constructor(
private noteEntityService: NoteEntityService, private noteEntityService: NoteEntityService,
@ -32,9 +31,8 @@ class HomeTimelineChannel extends Channel {
@bindThis @bindThis
public async init(params: any) { public async init(params: any) {
this.withReplies = params.withReplies ?? false;
this.withRenotes = params.withRenotes ?? true; this.withRenotes = params.withRenotes ?? true;
this.withFiles = params.withFiles as boolean; this.withFiles = params.withFiles ?? false;
this.subscriber.on('notesStream', this.onNote); this.subscriber.on('notesStream', this.onNote);
} }
@ -55,9 +53,6 @@ class HomeTimelineChannel extends Channel {
// Ignore notes from instances the user has muted // Ignore notes from instances the user has muted
if (isInstanceMuted(note, new Set<string>(this.userProfile!.mutedInstances))) return; if (isInstanceMuted(note, new Set<string>(this.userProfile!.mutedInstances))) return;
// ファイルを含まない投稿は除外
if (this.withFiles && (note.files === undefined || note.files.length === 0)) return;
if (note.visibility === 'followers') { if (note.visibility === 'followers') {
if (!isMe && !Object.hasOwn(this.following, note.userId)) return; if (!isMe && !Object.hasOwn(this.following, note.userId)) return;
} else if (note.visibility === 'specified') { } else if (note.visibility === 'specified') {

View File

@ -39,9 +39,9 @@ class HybridTimelineChannel extends Channel {
const policies = await this.roleService.getUserPolicies(this.user ? this.user.id : null); const policies = await this.roleService.getUserPolicies(this.user ? this.user.id : null);
if (!policies.ltlAvailable) return; if (!policies.ltlAvailable) return;
this.withReplies = params.withReplies ?? false;
this.withRenotes = params.withRenotes ?? true; this.withRenotes = params.withRenotes ?? true;
this.withFiles = params.withFiles as boolean; this.withReplies = params.withReplies ?? false;
this.withFiles = params.withFiles ?? false;
// Subscribe events // Subscribe events
this.subscriber.on('notesStream', this.onNote); this.subscriber.on('notesStream', this.onNote);
@ -64,9 +64,6 @@ class HybridTimelineChannel extends Channel {
(note.channelId != null && this.followingChannels.has(note.channelId)) (note.channelId != null && this.followingChannels.has(note.channelId))
)) return; )) return;
// ファイルを含まない投稿は除外
if (this.withFiles && (note.files === undefined || note.files.length === 0)) return;
if (note.visibility === 'followers') { if (note.visibility === 'followers') {
if (!isMe && !Object.hasOwn(this.following, note.userId)) return; if (!isMe && !Object.hasOwn(this.following, note.userId)) return;
} else if (note.visibility === 'specified') { } else if (note.visibility === 'specified') {
@ -75,7 +72,6 @@ class HybridTimelineChannel extends Channel {
// Ignore notes from instances the user has muted // Ignore notes from instances the user has muted
if (isInstanceMuted(note, new Set<string>(this.userProfile!.mutedInstances))) return; if (isInstanceMuted(note, new Set<string>(this.userProfile!.mutedInstances))) return;
// 関係ない返信は除外 // 関係ない返信は除外
if (note.reply && !this.following[note.userId]?.withReplies && !this.withReplies) { if (note.reply && !this.following[note.userId]?.withReplies && !this.withReplies) {
const reply = note.reply; const reply = note.reply;

View File

@ -40,7 +40,7 @@ class LocalTimelineChannel extends Channel {
this.withRenotes = params.withRenotes ?? true; this.withRenotes = params.withRenotes ?? true;
this.withReplies = params.withReplies ?? false; this.withReplies = params.withReplies ?? false;
this.withFiles = params.withFiles as boolean; this.withFiles = params.withFiles ?? false;
// Subscribe events // Subscribe events
this.subscriber.on('notesStream', this.onNote); this.subscriber.on('notesStream', this.onNote);
@ -48,26 +48,12 @@ class LocalTimelineChannel extends Channel {
@bindThis @bindThis
private async onNote(note: Packed<'Note'>) { private async onNote(note: Packed<'Note'>) {
if (this.withFiles && (note.fileIds == null || note.fileIds.length === 0)) return;
if (note.user.host !== null) return; if (note.user.host !== null) return;
if (note.visibility !== 'public') return; if (note.visibility !== 'public') return;
if (note.channelId != null && !this.followingChannels.has(note.channelId)) return; if (note.channelId != null && !this.followingChannels.has(note.channelId)) return;
// ファイルを含まない投稿は除外
if (this.withFiles && (note.files === undefined || note.files.length === 0)) return;
// リプライなら再pack
if (note.replyId != null) {
note.reply = await this.noteEntityService.pack(note.replyId, this.user, {
detail: true,
});
}
// Renoteなら再pack
if (note.renoteId != null) {
note.renote = await this.noteEntityService.pack(note.renoteId, this.user, {
detail: true,
});
}
// 関係ない返信は除外 // 関係ない返信は除外
if (note.reply && this.user && !this.following[note.userId]?.withReplies && !this.withReplies) { if (note.reply && this.user && !this.following[note.userId]?.withReplies && !this.withReplies) {
const reply = note.reply; const reply = note.reply;

View File

@ -4,30 +4,30 @@ SPDX-License-Identifier: AGPL-3.0-only
--> -->
<template> <template>
<MkStickyContainer> <MkStickyContainer>
<template #header><MkPageHeader v-model:tab="src" :actions="headerActions" :tabs="$i ? headerTabs : headerTabsWhenNotLogin" :displayMyAvatar="true"/></template> <template #header><MkPageHeader v-model:tab="src" :actions="headerActions" :tabs="$i ? headerTabs : headerTabsWhenNotLogin" :displayMyAvatar="true"/></template>
<MkSpacer :contentMax="800"> <MkSpacer :contentMax="800">
<div ref="rootEl" v-hotkey.global="keymap"> <div ref="rootEl" v-hotkey.global="keymap">
<XTutorial v-if="$i && defaultStore.reactiveState.timelineTutorial.value != -1" class="_panel" style="margin-bottom: var(--margin);"/> <XTutorial v-if="$i && defaultStore.reactiveState.timelineTutorial.value != -1" class="_panel" style="margin-bottom: var(--margin);"/>
<MkPostForm v-if="defaultStore.reactiveState.showFixedPostForm.value" :class="$style.postForm" class="post-form _panel" fixed style="margin-bottom: var(--margin);"/> <MkPostForm v-if="defaultStore.reactiveState.showFixedPostForm.value" :class="$style.postForm" class="post-form _panel" fixed style="margin-bottom: var(--margin);"/>
<div v-if="queue > 0" :class="$style.new"><button class="_buttonPrimary" :class="$style.newButton" @click="top()">{{ i18n.ts.newNoteRecived }}</button></div> <div v-if="queue > 0" :class="$style.new"><button class="_buttonPrimary" :class="$style.newButton" @click="top()">{{ i18n.ts.newNoteRecived }}</button></div>
<div :class="$style.tl"> <div :class="$style.tl">
<MkTimeline <MkTimeline
ref="tlComponent" ref="tlComponent"
:key="src + withRenotes + withReplies + onlyFiles" :key="src + withRenotes + withReplies + onlyFiles"
:src="src.split(':')[0]" :src="src.split(':')[0]"
:list="src.split(':')[1]" :list="src.split(':')[1]"
:withRenotes="withRenotes" :withRenotes="withRenotes"
:withReplies="withReplies" :withReplies="withReplies"
:onlyFiles="onlyFiles" :onlyFiles="onlyFiles"
:sound="true" :sound="true"
@queue="queueUpdated" @queue="queueUpdated"
/> />
</div> </div>
</div> </div>
</MkSpacer> </MkSpacer>
</MkStickyContainer> </MkStickyContainer>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
@ -52,7 +52,7 @@ const XTutorial = defineAsyncComponent(() => import('./timeline.tutorial.vue'));
const isLocalTimelineAvailable = ($i == null && instance.policies.ltlAvailable) || ($i != null && $i.policies.ltlAvailable); const isLocalTimelineAvailable = ($i == null && instance.policies.ltlAvailable) || ($i != null && $i.policies.ltlAvailable);
const isGlobalTimelineAvailable = ($i == null && instance.policies.gtlAvailable && defaultStore.state.showGlobalTimeline) || ($i != null && $i.policies.gtlAvailable && defaultStore.state.showGlobalTimeline); const isGlobalTimelineAvailable = ($i == null && instance.policies.gtlAvailable && defaultStore.state.showGlobalTimeline) || ($i != null && $i.policies.gtlAvailable && defaultStore.state.showGlobalTimeline);
const keymap = { const keymap = {
't': focus, 't': focus,
}; };
const tlComponent = $shallowRef<InstanceType<typeof MkTimeline>>(); const tlComponent = $shallowRef<InstanceType<typeof MkTimeline>>();
@ -61,205 +61,202 @@ const rootEl = $shallowRef<HTMLElement>();
let queue = $ref(0); let queue = $ref(0);
let srcWhenNotSignin = $ref(isLocalTimelineAvailable ? 'local' : 'global'); let srcWhenNotSignin = $ref(isLocalTimelineAvailable ? 'local' : 'global');
const src = $computed({ get: () => ($i ? defaultStore.reactiveState.tl.value.src : srcWhenNotSignin), set: (x) => saveSrc(x) }); const src = $computed({ get: () => ($i ? defaultStore.reactiveState.tl.value.src : srcWhenNotSignin), set: (x) => saveSrc(x) });
const withReplies_store = computed(defaultStore.makeGetterSetter('withRenotes')) const withRenotes = $ref(true);
const withRenotes_store = computed(defaultStore.makeGetterSetter('withReplies')) const withReplies = $ref($i ? defaultStore.state.tlWithReplies : false);
const onlyFiles_store = computed(defaultStore.makeGetterSetter('onlyFiles')) const onlyFiles = $ref(false);
const withRenotes = $ref(defaultStore.state.onlyAndWithSave ? withRenotes_store : true);
const withReplies = $ref(defaultStore.state.onlyAndWithSave ? withReplies_store : true);
const onlyFiles = $ref(defaultStore.state.onlyAndWithSave ? onlyFiles_store : false);
const isShowMediaTimeline = $ref(defaultStore.state.showMediaTimeline) const isShowMediaTimeline = $ref(defaultStore.state.showMediaTimeline)
watch($$(src), () => queue = 0); watch($$(src), () => queue = 0);
watch($$(withReplies), (x) => { watch($$(withReplies), (x) => {
if ($i) defaultStore.set('tlWithReplies', x); if ($i) defaultStore.set('tlWithReplies', x);
}); });
function queueUpdated(q: number): void { function queueUpdated(q: number): void {
queue = q; queue = q;
} }
function top(): void { function top(): void {
if (rootEl) scroll(rootEl, { top: 0 }); if (rootEl) scroll(rootEl, { top: 0 });
} }
async function chooseList(ev: MouseEvent): Promise<void> { async function chooseList(ev: MouseEvent): Promise<void> {
const lists = await userListsCache.fetch(); const lists = await userListsCache.fetch();
const items = lists.map(list => ({ const items = lists.map(list => ({
type: 'link' as const, type: 'link' as const,
text: list.name, text: list.name,
to: `/timeline/list/${list.id}`, to: `/timeline/list/${list.id}`,
})); }));
os.popupMenu(items, ev.currentTarget ?? ev.target); os.popupMenu(items, ev.currentTarget ?? ev.target);
} }
async function chooseAntenna(ev: MouseEvent): Promise<void> { async function chooseAntenna(ev: MouseEvent): Promise<void> {
const antennas = await antennasCache.fetch(); const antennas = await antennasCache.fetch();
const items = antennas.map(antenna => ({ const items = antennas.map(antenna => ({
type: 'link' as const, type: 'link' as const,
text: antenna.name, text: antenna.name,
indicate: antenna.hasUnreadNote, indicate: antenna.hasUnreadNote,
to: `/timeline/antenna/${antenna.id}`, to: `/timeline/antenna/${antenna.id}`,
})); }));
os.popupMenu(items, ev.currentTarget ?? ev.target); os.popupMenu(items, ev.currentTarget ?? ev.target);
} }
async function chooseChannel(ev: MouseEvent): Promise<void> { async function chooseChannel(ev: MouseEvent): Promise<void> {
const channels = await os.api('channels/my-favorites', { const channels = await os.api('channels/my-favorites', {
limit: 100, limit: 100,
}); });
const items = channels.map(channel => ({ const items = channels.map(channel => ({
type: 'link' as const, type: 'link' as const,
text: channel.name, text: channel.name,
indicate: channel.hasUnreadNote, indicate: channel.hasUnreadNote,
to: `/channels/${channel.id}`, to: `/channels/${channel.id}`,
})); }));
os.popupMenu(items, ev.currentTarget ?? ev.target); os.popupMenu(items, ev.currentTarget ?? ev.target);
} }
function saveSrc(newSrc: 'home' | 'local' | 'social' | 'global' | `list:${string}`): void { function saveSrc(newSrc: 'home' | 'local' | 'media' | 'social' | 'global' | `list:${string}`): void {
let userList = null; let userList = null;
if (newSrc.startsWith('userList:')) { if (newSrc.startsWith('userList:')) {
const id = newSrc.substring('userList:'.length); const id = newSrc.substring('userList:'.length);
userList = defaultStore.reactiveState.pinnedUserLists.value.find(l => l.id === id); userList = defaultStore.reactiveState.pinnedUserLists.value.find(l => l.id === id);
} }
defaultStore.set('tl', { defaultStore.set('tl', {
src: newSrc, src: newSrc,
userList, userList,
}); });
srcWhenNotSignin = newSrc; srcWhenNotSignin = newSrc;
} }
async function timetravel(): Promise<void> { async function timetravel(): Promise<void> {
const { canceled, result: date } = await os.inputDate({ const { canceled, result: date } = await os.inputDate({
title: i18n.ts.date, title: i18n.ts.date,
}); });
if (canceled) return; if (canceled) return;
tlComponent.timetravel(date); tlComponent.timetravel(date);
} }
function focus(): void { function focus(): void {
tlComponent.focus(); tlComponent.focus();
} }
const headerActions = $computed(() => [{ const headerActions = $computed(() => [{
icon: 'ti ti-dots', icon: 'ti ti-dots',
text: i18n.ts.options, text: i18n.ts.options,
handler: (ev) => { handler: (ev) => {
os.popupMenu([{ os.popupMenu([{
type: 'switch', type: 'switch',
text: i18n.ts.showRenotes, text: i18n.ts.showRenotes,
icon: 'ti ti-repeat', icon: 'ti ti-repeat',
ref: $$(withRenotes), ref: $$(withRenotes),
}, { }, src === 'local' || src === 'social' ? {
type: 'switch', type: 'switch',
text: i18n.ts.withReplies, text: i18n.ts.showRepliesToOthersInTimeline,
icon: 'ti ti-arrow-back-up', ref: $$(withReplies),
ref: $$(withReplies), } : undefined, {
}, { type: 'switch',
type: 'switch', text: i18n.ts.fileAttachedOnly,
text: i18n.ts.fileAttachedOnly, icon: 'ti ti-photo',
icon: 'ti ti-photo', ref: $$(onlyFiles),
ref: $$(onlyFiles), }], ev.currentTarget ?? ev.target);
}], ev.currentTarget ?? ev.target); },
},
}]); }]);
const headerTabs = $computed(() => [...(defaultStore.reactiveState.pinnedUserLists.value.map(l => ({ const headerTabs = $computed(() => [...(defaultStore.reactiveState.pinnedUserLists.value.map(l => ({
key: 'list:' + l.id, key: 'list:' + l.id,
title: l.name, title: l.name,
icon: 'ti ti-star', icon: 'ti ti-star',
iconOnly: true, iconOnly: true,
}))), { }))), {
key: 'home', key: 'home',
title: i18n.ts._timelines.home, title: i18n.ts._timelines.home,
icon: 'ti ti-home', icon: 'ti ti-home',
iconOnly: true, iconOnly: true,
}, ...(isLocalTimelineAvailable ? [{ }, ...(isLocalTimelineAvailable ? [{
key: 'local', key: 'local',
title: i18n.ts._timelines.local, title: i18n.ts._timelines.local,
icon: 'ti ti-planet', icon: 'ti ti-planet',
iconOnly: true, iconOnly: true,
}, ...(isShowMediaTimeline ? [{ }, ...(isShowMediaTimeline ? [{
key: 'media', key: 'media',
title: i18n.ts._timelines.media, title: i18n.ts._timelines.media,
icon: 'ti ti-photo', icon: 'ti ti-photo',
iconOnly: true, iconOnly: true,
}] : []),{
key: 'social',
title: i18n.ts._timelines.social,
icon: 'ti ti-rocket',
iconOnly: true,
}] : []), ...(isGlobalTimelineAvailable ? [{
key: 'global',
title: i18n.ts._timelines.global,
icon: 'ti ti-whirl',
iconOnly: true,
}] : []), { }] : []), {
icon: 'ti ti-list', key: 'social',
title: i18n.ts.lists, title: i18n.ts._timelines.social,
iconOnly: true, icon: 'ti ti-universe',
onClick: chooseList, iconOnly: true,
}] : []), ...(isGlobalTimelineAvailable ? [{
key: 'global',
title: i18n.ts._timelines.global,
icon: 'ti ti-whirl',
iconOnly: true,
}] : []), {
icon: 'ti ti-list',
title: i18n.ts.lists,
iconOnly: true,
onClick: chooseList,
}, { }, {
icon: 'ti ti-antenna', icon: 'ti ti-antenna',
title: i18n.ts.antennas, title: i18n.ts.antennas,
iconOnly: true, iconOnly: true,
onClick: chooseAntenna, onClick: chooseAntenna,
}, { }, {
icon: 'ti ti-device-tv', icon: 'ti ti-device-tv',
title: i18n.ts.channel, title: i18n.ts.channel,
iconOnly: true, iconOnly: true,
onClick: chooseChannel, onClick: chooseChannel,
}] as Tab[]); }] as Tab[]);
const headerTabsWhenNotLogin = $computed(() => [ const headerTabsWhenNotLogin = $computed(() => [
...(isLocalTimelineAvailable ? [{ ...(isLocalTimelineAvailable ? [{
key: 'local', key: 'local',
title: i18n.ts._timelines.local, title: i18n.ts._timelines.local,
icon: 'ti ti-planet', icon: 'ti ti-planet',
iconOnly: true, iconOnly: true,
}] : []), }] : []),
...(isGlobalTimelineAvailable ? [{ ...(isGlobalTimelineAvailable ? [{
key: 'global', key: 'global',
title: i18n.ts._timelines.global, title: i18n.ts._timelines.global,
icon: 'ti ti-whirl', icon: 'ti ti-whirl',
iconOnly: true, iconOnly: true,
}] : []), }] : []),
] as Tab[]); ] as Tab[]);
definePageMetadata(computed(() => ({ definePageMetadata(computed(() => ({
title: i18n.ts.timeline, title: i18n.ts.timeline,
icon: src === 'local' ? 'ti ti-planet' : src === 'social' ? 'ti ti-universe' : src === 'global' ? 'ti ti-whirl' : 'ti ti-home', icon: src === 'local' ? 'ti ti-planet' : src === 'social' ? 'ti ti-universe' : src === 'global' ? 'ti ti-whirl' : 'ti ti-home',
}))); })));
</script> </script>
<style lang="scss" module> <style lang="scss" module>
.new { .new {
position: sticky; position: sticky;
top: calc(var(--stickyTop, 0px) + 16px); top: calc(var(--stickyTop, 0px) + 16px);
z-index: 1000; z-index: 1000;
width: 100%; width: 100%;
margin: calc(-0.675em - 8px) 0; margin: calc(-0.675em - 8px) 0;
&:first-child { &:first-child {
margin-top: calc(-0.675em - 8px - var(--margin)); margin-top: calc(-0.675em - 8px - var(--margin));
} }
} }
.newButton { .newButton {
display: block; display: block;
margin: var(--margin) auto 0 auto; margin: var(--margin) auto 0 auto;
padding: 8px 16px; padding: 8px 16px;
border-radius: 32px; border-radius: 32px;
} }
.postForm { .postForm {
border-radius: var(--radius); border-radius: var(--radius);
} }
.tl { .tl {
background: var(--bg); background: var(--bg);
border-radius: var(--radius); border-radius: var(--radius);
overflow: clip; overflow: clip;
} }
</style> </style>