diff --git a/src/utils.ts b/src/utils.ts index b034a11..2fb61f1 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -7,6 +7,9 @@ export function toUndefined(opt: Option) { return opt.isSome() ? opt.unwrap() : undefined; } +/** + * Converts a null value to an option. + */ export function toOption(val: T): Option { return Some(val || undefined); } diff --git a/src/websocket.ts b/src/websocket.ts index 3bf7479..4c7822b 100644 --- a/src/websocket.ts +++ b/src/websocket.ts @@ -647,26 +647,9 @@ export class LemmyWebsocket { function wrapper(op: UserOperation, data: MessageType) { let send = serialize({ op: UserOperation[op], data }); - console.log(send); return send; } -/** - * A websocket JSON response that includes the errors. - */ -// interface WebSocketJsonResponse { -// op?: string; - -// /** -// * This contains the data for a websocket response. -// * -// * The correct response type if given is in [[LemmyHttp]]. -// */ -// data?: ResponseType; -// error?: string; -// reconnect?: boolean; -// } - export function wsUserOp(msg: any): UserOperation { let opStr: string = msg.op; return UserOperation[opStr as keyof typeof UserOperation]; @@ -679,5 +662,6 @@ export function wsJsonToRes( msg: any, responseClass: ClassConstructor ): ResponseType { + // Have to deserialize the response again into the correct class return deserialize(responseClass, serialize(msg.data)); }