refactor(user): remove unused view fields
This commit is contained in:
@@ -10,25 +10,13 @@ describe("toView", () => {
|
||||
expect(toView({ id: "user-1", username: "Luna" })).toEqual({
|
||||
id: "user-1",
|
||||
username: "Luna",
|
||||
email: "",
|
||||
country: "",
|
||||
countryCode: "",
|
||||
avatarUrl: "",
|
||||
intimacy: 0,
|
||||
dolBalance: 0,
|
||||
creditBalance: 0,
|
||||
dailyFreeChatLimit: 0,
|
||||
dailyFreeChatUsed: 0,
|
||||
dailyFreeChatRemaining: 0,
|
||||
dailyFreePrivateLimit: 0,
|
||||
dailyFreePrivateUsed: 0,
|
||||
dailyFreePrivateRemaining: 0,
|
||||
vipExpiresAt: null,
|
||||
relationshipStage: "",
|
||||
currentMood: "",
|
||||
isGuest: false,
|
||||
isVip: false,
|
||||
voiceMinutesRemaining: 0,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -37,48 +25,25 @@ describe("toView", () => {
|
||||
toView({
|
||||
id: "user-2",
|
||||
username: "Elio",
|
||||
email: "elio@example.com",
|
||||
country: "Hong Kong",
|
||||
countryCode: "HK",
|
||||
avatarUrl: "https://example.com/avatar.png",
|
||||
intimacy: 42,
|
||||
dolBalance: 12,
|
||||
creditBalance: 120,
|
||||
dailyFreeChatLimit: 30,
|
||||
dailyFreeChatUsed: 4,
|
||||
dailyFreeChatRemaining: 26,
|
||||
dailyFreePrivateLimit: 2,
|
||||
dailyFreePrivateUsed: 1,
|
||||
dailyFreePrivateRemaining: 1,
|
||||
vipExpiresAt: "2026-07-26T00:00:00+00:00",
|
||||
relationshipStage: "close_friend",
|
||||
currentMood: "playful",
|
||||
isGuest: true,
|
||||
isVip: true,
|
||||
voiceMinutesRemaining: 30,
|
||||
}),
|
||||
).toEqual({
|
||||
id: "user-2",
|
||||
username: "Elio",
|
||||
email: "elio@example.com",
|
||||
country: "Hong Kong",
|
||||
countryCode: "HK",
|
||||
avatarUrl: "https://example.com/avatar.png",
|
||||
intimacy: 42,
|
||||
dolBalance: 12,
|
||||
creditBalance: 120,
|
||||
dailyFreeChatLimit: 30,
|
||||
dailyFreeChatUsed: 4,
|
||||
dailyFreeChatRemaining: 26,
|
||||
dailyFreePrivateLimit: 2,
|
||||
dailyFreePrivateUsed: 1,
|
||||
dailyFreePrivateRemaining: 1,
|
||||
vipExpiresAt: "2026-07-26T00:00:00+00:00",
|
||||
relationshipStage: "close_friend",
|
||||
currentMood: "playful",
|
||||
isGuest: true,
|
||||
isVip: true,
|
||||
voiceMinutesRemaining: 30,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -93,7 +58,6 @@ describe("toView", () => {
|
||||
).toMatchObject({
|
||||
isVip: true,
|
||||
creditBalance: 120,
|
||||
dolBalance: 120,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -12,25 +12,13 @@ function makeUser(overrides: Partial<UserView> = {}): UserView {
|
||||
return {
|
||||
id: "user-1",
|
||||
username: "Elio Fan",
|
||||
email: "user@example.com",
|
||||
country: "Hong Kong",
|
||||
countryCode: "HK",
|
||||
avatarUrl: "https://example.com/avatar.png",
|
||||
intimacy: 42,
|
||||
dolBalance: 7,
|
||||
creditBalance: 7,
|
||||
dailyFreeChatLimit: 30,
|
||||
dailyFreeChatUsed: 0,
|
||||
dailyFreeChatRemaining: 30,
|
||||
dailyFreePrivateLimit: 2,
|
||||
dailyFreePrivateUsed: 0,
|
||||
dailyFreePrivateRemaining: 2,
|
||||
vipExpiresAt: null,
|
||||
relationshipStage: "close_friend",
|
||||
currentMood: "happy",
|
||||
isGuest: false,
|
||||
isVip: false,
|
||||
voiceMinutesRemaining: 12,
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -56,50 +56,27 @@ export interface UserFetchData {
|
||||
export function toView(u: {
|
||||
id: string;
|
||||
username: string;
|
||||
email?: string;
|
||||
country?: string;
|
||||
countryCode?: string;
|
||||
avatarUrl?: string;
|
||||
intimacy?: number;
|
||||
dolBalance?: number;
|
||||
creditBalance?: number;
|
||||
dailyFreeChatLimit?: number;
|
||||
dailyFreeChatUsed?: number;
|
||||
dailyFreeChatRemaining?: number;
|
||||
dailyFreePrivateLimit?: number;
|
||||
dailyFreePrivateUsed?: number;
|
||||
dailyFreePrivateRemaining?: number;
|
||||
vipExpiresAt?: string | null;
|
||||
relationshipStage?: string;
|
||||
currentMood?: string;
|
||||
isGuest?: boolean;
|
||||
isVip?: boolean;
|
||||
voiceMinutesRemaining?: number;
|
||||
}): UserView {
|
||||
const creditBalance = u.creditBalance ?? u.dolBalance ?? 0;
|
||||
|
||||
return {
|
||||
id: u.id,
|
||||
username: u.username,
|
||||
email: u.email ?? "",
|
||||
country: u.country ?? "",
|
||||
countryCode: u.countryCode ?? "",
|
||||
avatarUrl: u.avatarUrl ?? "",
|
||||
intimacy: u.intimacy ?? 0,
|
||||
dolBalance: u.dolBalance ?? creditBalance,
|
||||
creditBalance,
|
||||
dailyFreeChatLimit: u.dailyFreeChatLimit ?? 0,
|
||||
dailyFreeChatUsed: u.dailyFreeChatUsed ?? 0,
|
||||
dailyFreeChatRemaining: u.dailyFreeChatRemaining ?? 0,
|
||||
dailyFreePrivateLimit: u.dailyFreePrivateLimit ?? 0,
|
||||
dailyFreePrivateUsed: u.dailyFreePrivateUsed ?? 0,
|
||||
dailyFreePrivateRemaining: u.dailyFreePrivateRemaining ?? 0,
|
||||
vipExpiresAt: u.vipExpiresAt ?? null,
|
||||
relationshipStage: u.relationshipStage ?? "",
|
||||
currentMood: u.currentMood ?? "",
|
||||
isGuest: u.isGuest ?? false,
|
||||
isVip: u.isVip ?? false,
|
||||
voiceMinutesRemaining: u.voiceMinutesRemaining ?? 0,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -111,7 +88,6 @@ export function applyEntitlementSnapshotToView(
|
||||
return {
|
||||
...user,
|
||||
isVip: snapshot.isVip,
|
||||
dolBalance: snapshot.creditBalance,
|
||||
creditBalance: snapshot.creditBalance,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user