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

View File

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