Skip to content

Commit

Permalink
fix sb profiles
Browse files Browse the repository at this point in the history
* Fixed selecting latest profile
* Players with no profiles no longer return an error
  • Loading branch information
builder-247 committed Nov 16, 2022
1 parent 152c206 commit 15896bf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion routes/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2062,7 +2062,7 @@ Consider supporting The Slothpixel Project on Patreon to help cover the hosting
// TODO: Update when buildProfile changed
const profile = await buildProfile(uuid, request.params.profile);
try {
const players = await populatePlayers(Object.keys(profile.members).map((uuid) => ({ uuid })));
const players = await populatePlayers(Object.keys(profile.members || {}).map((uuid) => ({ uuid })));
players.forEach((player) => {
profile.members[player.profile.uuid].player = player.profile;
});
Expand Down
5 changes: 4 additions & 1 deletion store/buildSkyBlockProfiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const processSkyBlock = require('../processors/processSkyBlock');
const { logger, generateJob, getData } = require('../util/utility');

function getLatestProfile(profiles) {
return Object.entries(profiles).find((profile) => profiles[profile].selected);
return Object.entries(profiles).find(([profile]) => profiles[profile].selected);
}

async function updateProfileList(key, profiles) {
Expand Down Expand Up @@ -54,6 +54,9 @@ async function buildProfile(uuid, id = null) {
} else {
profiles = await buildProfileList(uuid);
}
if (Object.entries(profiles).length === 0) {
return {};
}
// If no id is specified, use last played profile
if (id === null) {
[profile_id] = getLatestProfile(profiles);
Expand Down

0 comments on commit 15896bf

Please sign in to comment.