Skip to content

Commit

Permalink
get default avatar instead of not showing anything (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
TechnikTil authored Dec 8, 2024
1 parent 46580ad commit 96e7444
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion source/online/network/FunkinNetwork.hx
Original file line number Diff line number Diff line change
Expand Up @@ -262,13 +262,31 @@ class FunkinNetwork {
});

if (avatarResponse == null)
return null;
return getDefaultAvatar();

try {
var bytes = output.getBytes();
cacheAvatar.set(user, bytes);
return BitmapData.fromBytes(bytes);
}
catch (exc) {
trace(exc);
return getDefaultAvatar();
}
}

public static function getDefaultAvatar():BitmapData
{
var output = new BytesOutput();
var avatarResponse = FunkinNetwork.requestAPI({
path: 'images/bf' + FlxG.random.int(1, 2) + ".png",
bodyOutput: output
});

try {
var bytes = output.getBytes();
return BitmapData.fromBytes(bytes);
}
catch (exc) {
trace(exc);
return null;
Expand Down

0 comments on commit 96e7444

Please sign in to comment.