Skip to content

Commit cfb8df7

Browse files
committed
feat(userStatus): simplify user status response in LeetCode services
1 parent ff6cf11 commit cfb8df7

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/leetcode/leetcode-cn-service.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,15 @@ export class LeetCodeCNService implements LeetCodeBaseService {
3838
if (!this.isAuthenticated()) {
3939
throw new Error("Authentication required to fetch user status");
4040
}
41-
return await this.leetCodeApi.userStatus();
41+
return await this.leetCodeApi.userStatus().then((res) => {
42+
return {
43+
isSignedIn: res?.isSignedIn ?? false,
44+
username: res?.username ?? "",
45+
avatar: res?.avatar ?? "",
46+
isAdmin: res?.isAdmin ?? false,
47+
useTranslation: res?.useTranslation ?? false
48+
};
49+
});
4250
}
4351

4452
async fetchUserAllSubmissions(options: {

src/leetcode/leetcode-global-service.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,14 @@ export class LeetCodeGlobalService implements LeetCodeBaseService {
3232
if (!this.isAuthenticated()) {
3333
throw new Error("Authentication required to fetch user status");
3434
}
35-
return await this.leetCodeApi.whoami();
35+
return await this.leetCodeApi.whoami().then((res) => {
36+
return {
37+
isSignedIn: res?.isSignedIn ?? false,
38+
username: res?.username ?? "",
39+
avatar: res?.avatar ?? "",
40+
isAdmin: res?.isAdmin ?? false
41+
};
42+
});
3643
}
3744

3845
async fetchUserAllSubmissions(options: {

0 commit comments

Comments
 (0)