This commit is contained in:
tamaina 2021-09-12 15:53:04 +09:00
parent e2550e8ddd
commit e777feae9a
3 changed files with 9 additions and 7 deletions

View File

@ -47,7 +47,7 @@ export const refs = {
GalleryPost: packedGalleryPostSchema,
};
export type Packed<x extends keyof typeof refs> = PackRef<typeof refs[x]>
export type Packed<x extends keyof typeof refs> = PackRef<typeof refs[x]>;
type PackRef<s extends { properties: Obj, [x: string]: any }> = { [x in keyof s['properties']]: SchemaType<s['properties'][x]> };

View File

@ -5,6 +5,7 @@ import { Notes } from '@/models/index';
import { PackedNote } from '@/models/repositories/note';
import { checkWordMute } from '@/misc/check-word-mute';
import { isBlockerUserRelated } from '@/misc/is-blocker-user-related';
import { Packed } from '@/misc/schema';
export default class extends Channel {
public readonly chName = 'homeTimeline';
@ -18,7 +19,7 @@ export default class extends Channel {
}
@autobind
private async onNote(note: PackedNote) {
private async onNote(note: Packed<'Note'>) {
if (note.channelId) {
if (!this.followingChannels.has(note.channelId)) return;
} else {

View File

@ -6,7 +6,7 @@ import { UserProfile } from '@/models/entities/user-profile';
import { PackedUser } from '@/models/repositories/user';
import { PackedNotification } from '@/models/repositories/notification';
import { Note } from '@/models/entities/note';
import { PackedNote } from '@/models/repositories/note';
// import { Packed<'Note'> } from '@/models/repositories/note';
import { Antenna } from '@/models/entities/antenna';
import { DriveFile } from '@/models/entities/drive-file';
import { PackedDriveFile } from '@/models/repositories/drive-file';
@ -24,6 +24,7 @@ import { PackedReversiMatching } from '@/models/repositories/games/reversi/match
import { AbuseUserReport } from '@/models/entities/abuse-user-report';
import { PackedSignin } from '@/models/repositories/signin';
import { Page } from '@/models/entities/page';
import { Packed } from '@/misc/schema';
// 辞書(interface or type)から{ type, body }ユニオンを定義
// https://stackoverflow.com/questions/49311989/can-i-infer-the-type-of-a-value-using-extends-keyof-type
@ -59,9 +60,9 @@ export interface UserStreamTypes {
export interface MainStreamTypes {
notification: PackedNotification;
mention: PackedNote;
reply: PackedNote;
renote: PackedNote;
mention: Packed<'Note'>;
reply: Packed<'Note'>;
renote: Packed<'Note'>;
follow: PackedUser;
followed: PackedUser;
unfollow: PackedUser;
@ -288,7 +289,7 @@ export type StreamMessages = {
};
notes: {
name: 'notesStream';
spec: PackedNote;
spec: Packed<'Note'>;
};
};