Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
piloking committed Nov 16, 2024
1 parent 236c130 commit 9d20c15
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 59 deletions.
29 changes: 16 additions & 13 deletions packages/linejs/client/clients/base-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -610,15 +610,15 @@ export class BaseClient extends TypedEventEmitter<ClientEvents> {
const chat =
message.toType === LINETypes.MIDType._USER
? () => {
return this.getContact({ mid: sendIn });
}
return this.getContact({ mid: sendIn });
}
: undefined;

const group =
message.toType !== LINETypes.MIDType._USER
? async () => {
return (await this.getChats({ mids: [sendIn] })).chats[0];
}
return (await this.getChats({ mids: [sendIn] })).chats[0];
}
: (undefined as LooseType);

const getContact = () => {
Expand Down Expand Up @@ -1201,7 +1201,7 @@ export class BaseClient extends TypedEventEmitter<ClientEvents> {
}
return authToken;
}
throw new InternalError("TimeoutError", "checkQrCodeVerified timed out")
throw new InternalError("TimeoutError", "checkQrCodeVerified timed out");
}

public async requestSQR2(): Promise<string> {
Expand Down Expand Up @@ -1230,7 +1230,7 @@ export class BaseClient extends TypedEventEmitter<ClientEvents> {
this.storage.set("expire", tokenInfo[3] + tokenInfo[6]);
return tokenInfo[1];
}
throw new InternalError("TimeoutError", "checkQrCodeVerified timed out")
throw new InternalError("TimeoutError", "checkQrCodeVerified timed out");
}

/**
Expand All @@ -1257,7 +1257,7 @@ export class BaseClient extends TypedEventEmitter<ClientEvents> {
/**
* @description Will override.
*/
public decodeE2EEKeyV1(_data: LooseType, _secret: Buffer): LooseType { }
public decodeE2EEKeyV1(_data: LooseType, _secret: Buffer): LooseType {}

/**
* @description Will override.
Expand Down Expand Up @@ -1478,7 +1478,7 @@ export class BaseClient extends TypedEventEmitter<ClientEvents> {
* @param {object} [headers={}] - The headers of the request.
* @param {number} [timeOutMs=this.timeOutMs] - The timeout milliseconds of the request.
* @returns {Promise<LooseType>} The response.
*
*
* ---
* Use for functions that take one thrift struct argument
* ```
Expand Down Expand Up @@ -1520,7 +1520,7 @@ export class BaseClient extends TypedEventEmitter<ClientEvents> {
* @param {object} [headers={}] - The headers of the request.
* @param {number} [timeOutMs=this.timeOutMs] - The timeout milliseconds of the request.
* @returns {Promise<LooseType>} The response.
*
*
* ---
* Use for functions that take two or more arguments
* ```
Expand Down Expand Up @@ -1711,12 +1711,13 @@ export class BaseClient extends TypedEventEmitter<ClientEvents> {
return res;
} catch (error) {
if (error instanceof InternalError) {
throw error
throw error;
} else {
throw new InternalError(
"Request internal failed",
`${methodName}(${path}) -> ` + JSON.stringify({ ...(error as object) }),
{ error }
`${methodName}(${path}) -> ` +
JSON.stringify({ ...(error as object) }),
{ error },
);
}
}
Expand Down Expand Up @@ -2038,7 +2039,9 @@ export class BaseClient extends TypedEventEmitter<ClientEvents> {

private reqseqs: Record<string, number>;
public getReqseq(name: string = "talk"): number {
if (!this.reqseqs[name]) { this.reqseqs[name] = 0 };
if (!this.reqseqs[name]) {
this.reqseqs[name] = 0;
}
const seq = this.reqseqs[name];
this.reqseqs[name]++;
this.storage.set("reqseq", JSON.stringify(this.reqseqs));
Expand Down
9 changes: 5 additions & 4 deletions packages/linejs/client/clients/internal/square-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ export class SquareClient extends LiffClient {
continuationToken?: string;
subscriptionId?: number;
squareThreadMid?: string;
direction?: number
direction?: number;
}): Promise<LINETypes.FetchSquareChatEventsResponse> {
const {
squareChatMid,
Expand All @@ -326,10 +326,11 @@ export class SquareClient extends LiffClient {
squareThreadMid,
direction,
} = { limit: 100, direction: 1, ...options };
let _syncToken = syncToken, _direction = direction;
let _syncToken = syncToken,
_direction = direction;
if (continuationToken) {
_syncToken = continuationToken
_direction = 2
_syncToken = continuationToken;
_direction = 2;
}
return this.request(
[
Expand Down
20 changes: 10 additions & 10 deletions packages/linejs/client/clients/internal/talk-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -797,20 +797,20 @@ export class TalkClient extends ChannelClient {
chatSet.picturePath ? [11, 7, chatSet.picturePath] : null,
chatSet.extra?.groupExtra
? [
12,
8,
[
12,
8,
[
12,
1,
[
[2, 2, chatSet.extra.groupExtra.preventedJoinByTicket],
[2, 6, chatSet.extra.groupExtra.addFriendDisabled],
[2, 7, chatSet.extra.groupExtra.ticketDisabled],
12,
1,
[
[2, 2, chatSet.extra.groupExtra.preventedJoinByTicket],
[2, 6, chatSet.extra.groupExtra.addFriendDisabled],
[2, 7, chatSet.extra.groupExtra.ticketDisabled],
],
],
],
],
]
]
: null,
],
],
Expand Down
18 changes: 9 additions & 9 deletions packages/linejs/client/entities/square-class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type SquareEvents = {
"update:note": (note: LINETypes.NoteStatus) => void;
"update:authority": (authority: LINETypes.SquareAuthority) => void;
"update:square": (square: LINETypes.Square) => void;
"update": (square: Square) => void;
update: (square: Square) => void;
shutdown: (square: LINETypes.Square) => void;
};

Expand Down Expand Up @@ -254,7 +254,7 @@ export class SquareChat extends TypedEventEmitter<SquareChatEvents> {
if (
event.payload.notifiedUpdateSquareChatStatus &&
event.payload.notifiedUpdateSquareChatStatus.squareChatMid ===
this.mid
this.mid
) {
this.status =
event.payload.notifiedUpdateSquareChatStatus.statusWithoutMessage;
Expand Down Expand Up @@ -282,7 +282,7 @@ export class SquareChat extends TypedEventEmitter<SquareChatEvents> {
}
});
if (polling) {
this.on("event", (event) => { });
this.on("event", (event) => {});
}
}
}
Expand Down Expand Up @@ -317,12 +317,12 @@ export class SquareChat extends TypedEventEmitter<SquareChatEvents> {
options:
| string
| {
text?: string;
contentType?: number;
contentMetadata?: LooseType;
relatedMessageId?: string;
location?: LINETypes.Location;
},
text?: string;
contentType?: number;
contentMetadata?: LooseType;
relatedMessageId?: string;
location?: LINETypes.Location;
},
): Promise<LINETypes.SendMessageResponse> {
if (typeof options === "string") {
return this.send({ text: options });
Expand Down
42 changes: 19 additions & 23 deletions packages/linejs/client/entities/talk-class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type UserEvents = {

/**
* @description Gets mid's type
*
*
* USER(0),\
* ROOM(1),\
* GROUP(2),\
Expand Down Expand Up @@ -71,7 +71,7 @@ export class Note {
constructor(
public mid: string,
private client: Client,
) { }
) {}

public createPost(options: {
text?: string;
Expand Down Expand Up @@ -235,14 +235,14 @@ export class User extends TypedEventEmitter<UserEvents> {
options:
| string
| {
text?: string;
contentType?: number;
contentMetadata?: LooseType;
relatedMessageId?: string;
location?: LINETypes.Location;
chunk?: string[] | Buffer[];
e2ee?: boolean;
},
text?: string;
contentType?: number;
contentMetadata?: LooseType;
relatedMessageId?: string;
location?: LINETypes.Location;
chunk?: string[] | Buffer[];
e2ee?: boolean;
},
): Promise<LINETypes.Message> {
if (typeof options === "string") {
return this.send({ text: options });
Expand All @@ -256,9 +256,7 @@ export class User extends TypedEventEmitter<UserEvents> {
/**
* @description Kickout from group.
*/
public kick(
chatMid: string,
): Promise<LINETypes.DeleteOtherFromChatResponse> {
public kick(chatMid: string): Promise<LINETypes.DeleteOtherFromChatResponse> {
return this.client.deleteOtherFromChat({ to: chatMid, mid: this.mid });
}

Expand Down Expand Up @@ -391,14 +389,14 @@ export class Group extends TypedEventEmitter<GroupEvents> {
options:
| string
| {
text?: string;
contentType?: number;
contentMetadata?: LooseType;
relatedMessageId?: string;
location?: LINETypes.Location;
chunk?: string[] | Buffer[];
e2ee?: boolean;
},
text?: string;
contentType?: number;
contentMetadata?: LooseType;
relatedMessageId?: string;
location?: LINETypes.Location;
chunk?: string[] | Buffer[];
e2ee?: boolean;
},
): Promise<LINETypes.Message> {
if (typeof options === "string") {
return this.send({ text: options });
Expand Down Expand Up @@ -955,5 +953,3 @@ export class SendChatRemoved {
this.chatType = getMidType(op.param[1]);
}
}


0 comments on commit 9d20c15

Please sign in to comment.