forked from FoundKeyGang/FoundKey
refactor
This commit is contained in:
parent
091ef2e240
commit
ce12fc2b67
5 changed files with 85 additions and 86 deletions
|
@ -1,4 +1,4 @@
|
|||
import { Endpoints } from './endpoints';
|
||||
import { Endpoints } from './api.types';
|
||||
|
||||
const MK_API_ERROR = Symbol();
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Endpoints } from './endpoints';
|
||||
import { Endpoints } from './api.types';
|
||||
import Stream from './streaming';
|
||||
import { Acct } from './acct';
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ import { EventEmitter } from 'eventemitter3';
|
|||
import ReconnectingWebsocket from 'reconnecting-websocket';
|
||||
import { stringify } from 'querystring';
|
||||
import { markRaw } from '@vue/reactivity';
|
||||
import { DriveFile, MeDetailed, MessagingMessage, Note, Notification, PageEvent, User } from './entities';
|
||||
import { ChannelDef, NoteUpdatedEvent } from './streaming.types';
|
||||
|
||||
function urlQuery(obj: {}): string {
|
||||
return stringify(Object.entries(obj)
|
||||
|
@ -11,89 +11,6 @@ function urlQuery(obj: {}): string {
|
|||
.reduce((a, [k, v]) => (a[k] = v, a), {} as Record<string, any>));
|
||||
}
|
||||
|
||||
type FIXME = any;
|
||||
|
||||
type ChannelDef = {
|
||||
main: {
|
||||
events: {
|
||||
notification: (payload: Notification) => void;
|
||||
mention: (payload: Note) => void;
|
||||
reply: (payload: Note) => void;
|
||||
renote: (payload: Note) => void;
|
||||
follow: (payload: User) => void; // 自分が他人をフォローしたとき
|
||||
followed: (payload: User) => void; // 他人が自分をフォローしたとき
|
||||
unfollow: (payload: User) => void; // 自分が他人をフォロー解除したとき
|
||||
meUpdated: (payload: MeDetailed) => void;
|
||||
pageEvent: (payload: PageEvent) => void;
|
||||
urlUploadFinished: (payload: { marker: string; file: DriveFile; }) => void;
|
||||
readAllNotifications: () => void;
|
||||
unreadNotification: () => void;
|
||||
unreadMention: () => void;
|
||||
readAllUnreadMentions: () => void;
|
||||
unreadSpecifiedNote: () => void;
|
||||
readAllUnreadSpecifiedNotes: () => void;
|
||||
readAllMessagingMessages: () => void;
|
||||
unreadMessagingMessage: () => void;
|
||||
readAllAntennas: () => void;
|
||||
unreadAntenna: () => void;
|
||||
readAllAnnouncements: () => void;
|
||||
readAllChannels: () => void;
|
||||
unreadChannel: () => void;
|
||||
myTokenRegenerated: () => void;
|
||||
};
|
||||
};
|
||||
homeTimeline: {
|
||||
events: {
|
||||
note: (payload: Note) => void;
|
||||
};
|
||||
};
|
||||
localTimeline: {
|
||||
events: {
|
||||
note: (payload: Note) => void;
|
||||
};
|
||||
};
|
||||
hybridTimeline: {
|
||||
events: {
|
||||
note: (payload: Note) => void;
|
||||
};
|
||||
};
|
||||
globalTimeline: {
|
||||
events: {
|
||||
note: (payload: Note) => void;
|
||||
};
|
||||
};
|
||||
messaging: {
|
||||
events: {
|
||||
message: (payload: MessagingMessage) => void;
|
||||
deleted: (payload: MessagingMessage['id']) => void;
|
||||
read: (payload: MessagingMessage['id'][]) => void;
|
||||
typers: (payload: User[]) => void;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
type NoteUpdatedEvent = {
|
||||
id: Note['id'];
|
||||
type: 'reacted';
|
||||
body: {
|
||||
reaction: string;
|
||||
userId: User['id'];
|
||||
};
|
||||
} | {
|
||||
id: Note['id'];
|
||||
type: 'deleted';
|
||||
body: {
|
||||
deletedAt: string;
|
||||
};
|
||||
} | {
|
||||
id: Note['id'];
|
||||
type: 'pollVoted';
|
||||
body: {
|
||||
choice: number;
|
||||
userId: User['id'];
|
||||
};
|
||||
};
|
||||
|
||||
type StreamEvents = {
|
||||
_connected_: void;
|
||||
_disconnected_: void;
|
||||
|
|
82
src/streaming.types.ts
Normal file
82
src/streaming.types.ts
Normal file
|
@ -0,0 +1,82 @@
|
|||
import { DriveFile, MeDetailed, MessagingMessage, Note, Notification, PageEvent, User } from './entities';
|
||||
|
||||
export type ChannelDef = {
|
||||
main: {
|
||||
events: {
|
||||
notification: (payload: Notification) => void;
|
||||
mention: (payload: Note) => void;
|
||||
reply: (payload: Note) => void;
|
||||
renote: (payload: Note) => void;
|
||||
follow: (payload: User) => void; // 自分が他人をフォローしたとき
|
||||
followed: (payload: User) => void; // 他人が自分をフォローしたとき
|
||||
unfollow: (payload: User) => void; // 自分が他人をフォロー解除したとき
|
||||
meUpdated: (payload: MeDetailed) => void;
|
||||
pageEvent: (payload: PageEvent) => void;
|
||||
urlUploadFinished: (payload: { marker: string; file: DriveFile; }) => void;
|
||||
readAllNotifications: () => void;
|
||||
unreadNotification: () => void;
|
||||
unreadMention: () => void;
|
||||
readAllUnreadMentions: () => void;
|
||||
unreadSpecifiedNote: () => void;
|
||||
readAllUnreadSpecifiedNotes: () => void;
|
||||
readAllMessagingMessages: () => void;
|
||||
unreadMessagingMessage: () => void;
|
||||
readAllAntennas: () => void;
|
||||
unreadAntenna: () => void;
|
||||
readAllAnnouncements: () => void;
|
||||
readAllChannels: () => void;
|
||||
unreadChannel: () => void;
|
||||
myTokenRegenerated: () => void;
|
||||
};
|
||||
};
|
||||
homeTimeline: {
|
||||
events: {
|
||||
note: (payload: Note) => void;
|
||||
};
|
||||
};
|
||||
localTimeline: {
|
||||
events: {
|
||||
note: (payload: Note) => void;
|
||||
};
|
||||
};
|
||||
hybridTimeline: {
|
||||
events: {
|
||||
note: (payload: Note) => void;
|
||||
};
|
||||
};
|
||||
globalTimeline: {
|
||||
events: {
|
||||
note: (payload: Note) => void;
|
||||
};
|
||||
};
|
||||
messaging: {
|
||||
events: {
|
||||
message: (payload: MessagingMessage) => void;
|
||||
deleted: (payload: MessagingMessage['id']) => void;
|
||||
read: (payload: MessagingMessage['id'][]) => void;
|
||||
typers: (payload: User[]) => void;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export type NoteUpdatedEvent = {
|
||||
id: Note['id'];
|
||||
type: 'reacted';
|
||||
body: {
|
||||
reaction: string;
|
||||
userId: User['id'];
|
||||
};
|
||||
} | {
|
||||
id: Note['id'];
|
||||
type: 'deleted';
|
||||
body: {
|
||||
deletedAt: string;
|
||||
};
|
||||
} | {
|
||||
id: Note['id'];
|
||||
type: 'pollVoted';
|
||||
body: {
|
||||
choice: number;
|
||||
userId: User['id'];
|
||||
};
|
||||
};
|
Loading…
Reference in a new issue