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) {
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
const timeline = await query.limit(ps.limit).getMany();

View File

@ -18,9 +18,8 @@ class GlobalTimelineChannel extends Channel {
public readonly chName = 'globalTimeline';
public static shouldShare = false;
public static requireCredential = false;
private withReplies: boolean;
private withFiles: boolean;
private withRenotes: boolean;
private withFiles: boolean;
constructor(
private metaService: MetaService,
@ -39,7 +38,6 @@ class GlobalTimelineChannel extends Channel {
const policies = await this.roleService.getUserPolicies(this.user ? this.user.id : null);
if (!policies.gtlAvailable) return;
this.withReplies = params.withReplies ?? false;
this.withRenotes = params.withRenotes ?? true;
this.withFiles = params.withFiles ?? false;
@ -49,25 +47,11 @@ class GlobalTimelineChannel extends Channel {
@bindThis
private async onNote(note: Packed<'Note'>) {
if (this.withFiles && (note.fileIds == null || note.fileIds.length === 0)) return;
if (note.visibility !== 'public') 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) {
const reply = note.reply;

View File

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

View File

@ -40,7 +40,7 @@ class LocalTimelineChannel extends Channel {
this.withRenotes = params.withRenotes ?? true;
this.withReplies = params.withReplies ?? false;
this.withFiles = params.withFiles as boolean;
this.withFiles = params.withFiles ?? false;
// Subscribe events
this.subscriber.on('notesStream', this.onNote);
@ -48,26 +48,12 @@ class LocalTimelineChannel extends Channel {
@bindThis
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.visibility !== 'public') 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) {
const reply = note.reply;

View File

@ -27,7 +27,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</div>
</div>
</MkSpacer>
</MkStickyContainer>
</MkStickyContainer>
</template>
<script lang="ts" setup>
@ -61,13 +61,11 @@ const rootEl = $shallowRef<HTMLElement>();
let queue = $ref(0);
let srcWhenNotSignin = $ref(isLocalTimelineAvailable ? 'local' : 'global');
const src = $computed({ get: () => ($i ? defaultStore.reactiveState.tl.value.src : srcWhenNotSignin), set: (x) => saveSrc(x) });
const withReplies_store = computed(defaultStore.makeGetterSetter('withRenotes'))
const withRenotes_store = computed(defaultStore.makeGetterSetter('withReplies'))
const onlyFiles_store = computed(defaultStore.makeGetterSetter('onlyFiles'))
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 withRenotes = $ref(true);
const withReplies = $ref($i ? defaultStore.state.tlWithReplies : false);
const onlyFiles = $ref(false);
const isShowMediaTimeline = $ref(defaultStore.state.showMediaTimeline)
watch($$(src), () => queue = 0);
watch($$(withReplies), (x) => {
@ -116,7 +114,7 @@ async function chooseChannel(ev: MouseEvent): Promise<void> {
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;
if (newSrc.startsWith('userList:')) {
const id = newSrc.substring('userList:'.length);
@ -151,12 +149,11 @@ const headerActions = $computed(() => [{
text: i18n.ts.showRenotes,
icon: 'ti ti-repeat',
ref: $$(withRenotes),
}, {
}, src === 'local' || src === 'social' ? {
type: 'switch',
text: i18n.ts.withReplies,
icon: 'ti ti-arrow-back-up',
text: i18n.ts.showRepliesToOthersInTimeline,
ref: $$(withReplies),
}, {
} : undefined, {
type: 'switch',
text: i18n.ts.fileAttachedOnly,
icon: 'ti ti-photo',
@ -185,10 +182,10 @@ const headerTabs = $computed(() => [...(defaultStore.reactiveState.pinnedUserLis
title: i18n.ts._timelines.media,
icon: 'ti ti-photo',
iconOnly: true,
}] : []),{
}] : []), {
key: 'social',
title: i18n.ts._timelines.social,
icon: 'ti ti-rocket',
icon: 'ti ti-universe',
iconOnly: true,
}] : []), ...(isGlobalTimelineAvailable ? [{
key: 'global',