Skip to content

Commit

Permalink
fix: Fix undefined properties in api v2
Browse files Browse the repository at this point in the history
  • Loading branch information
cyperdark committed Apr 28, 2024
1 parent bfe7d82 commit 6598271
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions packages/tosu/src/api/utils/buildResultV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export const buildResult = (
return {
state: {
number: allTimesData.Status,
name: GameState[allTimesData.Status]
name: GameState[allTimesData.Status] || ''
},
session: {
playTime: allTimesData.GameTime,
Expand All @@ -114,7 +114,7 @@ export const buildResult = (
replayUIVisible: gamePlayData.isReplayUiHidden === false,
chatVisibilityStatus: {
number: allTimesData.ChatStatus,
name: ChatStatus[allTimesData.ChatStatus]
name: ChatStatus[allTimesData.ChatStatus] || ''
},

leaderboard: {
Expand All @@ -123,13 +123,13 @@ export const buildResult = (
: false,
type: {
number: settings.leaderboardType,
name: LeaderboardType[settings.leaderboardType]
name: LeaderboardType[settings.leaderboardType] || ''
}
},

progressBar: {
number: settings.progressBarType,
name: ProgressBarType[settings.progressBarType]
name: ProgressBarType[settings.progressBarType] || ''
},
bassDensity: bassDensityData.density,

Expand All @@ -139,7 +139,7 @@ export const buildResult = (
scoreMeter: {
type: {
number: settings.scoreMeter.type,
name: ScoreMeterType[settings.scoreMeter.type]
name: ScoreMeterType[settings.scoreMeter.type] || ''
},
size: settings.scoreMeter.size
},
Expand All @@ -149,17 +149,17 @@ export const buildResult = (

sort: {
number: settings.sortType,
name: SortType[settings.sortType]
name: SortType[settings.sortType] || ''
},
group: {
number: settings.groupType,
name: GroupType[settings.groupType]
name: GroupType[settings.groupType] || ''
},

skin: settings.skin,
mode: {
number: menuData.MenuGameMode,
name: Modes[menuData.MenuGameMode]
name: Modes[menuData.MenuGameMode] || ''
},
audio: {
...settings.audio,
Expand All @@ -172,17 +172,17 @@ export const buildResult = (
profile: {
userStatus: {
number: userProfile.rawLoginStatus,
name: UserLoginStatus[userProfile.rawLoginStatus]
name: UserLoginStatus[userProfile.rawLoginStatus] || ''
},
banchoStatus: {
number: userProfile.rawBanchoStatus,
name: BanchoStatusEnum[userProfile.rawBanchoStatus]
name: BanchoStatusEnum[userProfile.rawBanchoStatus] || ''
},
id: userProfile.id,
name: userProfile.name,
mode: {
number: userProfile.playMode,
name: Modes[userProfile.playMode]
name: Modes[userProfile.playMode] || ''
},

rankedScore: userProfile.rankedScore,
Expand All @@ -209,7 +209,7 @@ export const buildResult = (
},
status: {
number: menuData.RankedStatus,
name: BeatmapStatuses[menuData.RankedStatus || -1]
name: BeatmapStatuses[menuData.RankedStatus || -1] || ''
},
checksum: menuData.MD5,

Expand Down Expand Up @@ -328,7 +328,7 @@ export const buildResult = (

mode: {
number: gamePlayData.Mode,
name: Modes[gamePlayData.Mode]
name: Modes[gamePlayData.Mode] || ''
},

score: gamePlayData.Score,
Expand Down Expand Up @@ -384,7 +384,7 @@ export const buildResult = (
resultsScreen: {
mode: {
number: gamePlayData.Mode,
name: Modes[gamePlayData.Mode]
name: Modes[gamePlayData.Mode] || ''
},
score: resultsScreenData.Score,
name: resultsScreenData.PlayerName,
Expand Down Expand Up @@ -508,7 +508,7 @@ const buildTourneyData = (

mode: {
number: gamePlayData.Mode,
name: Modes[gamePlayData.Mode]
name: Modes[gamePlayData.Mode] || ''
},

score: gamePlayData.Score,
Expand Down

0 comments on commit 6598271

Please sign in to comment.