forked from FoundKeyGang/FoundKey
Narrow type of isPureRenote
As side effect of that, a non-null assertion can be removed. Co-authored-by: Johann150 <johann.galle@protonmail.com>
This commit is contained in:
parent
47b2f619a6
commit
c282ed7683
2 changed files with 2 additions and 6 deletions
|
@ -1,5 +1,5 @@
|
|||
import { Note } from '@/models/entities/note.js';
|
||||
|
||||
export function isPureRenote(note: Note): boolean {
|
||||
export function isPureRenote(note: Note): note is Note & { renoteId: string, text: null, fileIds: null | never[], hasPoll: false } {
|
||||
return note.renoteId != null && note.text == null && (note.fileIds == null || note.fileIds.length === 0) && !note.hasPoll;
|
||||
}
|
||||
|
|
|
@ -43,11 +43,7 @@ export default async function(user: { id: User['id']; uri: User['uri']; host: Us
|
|||
|
||||
// if deleted note is renote
|
||||
if (isPureRenote(note)) {
|
||||
renote = await Notes.findOneBy({
|
||||
// isPureRenote checks if note.renoteId is null already, so renoteId should be non-null.
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
id: note.renoteId!,
|
||||
});
|
||||
renote = await Notes.findOneBy({ id: note.renoteId });
|
||||
}
|
||||
|
||||
const content = renderActivity(renote
|
||||
|
|
Loading…
Reference in a new issue