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

@ -61,13 +61,11 @@ 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) => {
@ -116,7 +114,7 @@ async function chooseChannel(ev: MouseEvent): Promise<void> {
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);
@ -151,12 +149,11 @@ const headerActions = $computed(() => [{
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',
@ -188,7 +185,7 @@ const headerTabs = $computed(() => [...(defaultStore.reactiveState.pinnedUserLis
}] : []), { }] : []), {
key: 'social', key: 'social',
title: i18n.ts._timelines.social, title: i18n.ts._timelines.social,
icon: 'ti ti-rocket', icon: 'ti ti-universe',
iconOnly: true, iconOnly: true,
}] : []), ...(isGlobalTimelineAvailable ? [{ }] : []), ...(isGlobalTimelineAvailable ? [{
key: 'global', key: 'global',