if totalXP calculation is negative, reset to 0 (#1107)

This commit is contained in:
ggurdin 2024-11-25 14:56:46 -05:00 committed by GitHub
parent b3ed80215a
commit 7ff4efadbc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 5 deletions

View file

@ -139,13 +139,17 @@ class ConstructListModel {
(total, construct) => total + construct.points,
);
if (totalXP < 0) {
totalXP = 0;
}
// Don't call .floor() if NaN or Infinity
// https://pangea-chat.sentry.io/issues/6052871310
final double levelCalculation = 1 + sqrt((1 + 8 * totalXP / 100) / 2);
if (!levelCalculation.isNaN && levelCalculation.isFinite) {
level = levelCalculation.floor();
} else {
level = 0;
level = 1;
Sentry.addBreadcrumb(
Breadcrumb(
data: {

View file

@ -172,8 +172,10 @@ class MessageTranslationCardState extends State<MessageTranslationCard> {
const Row(
mainAxisSize: MainAxisSize.min,
children: [
InlineTooltip(
instructionsEnum: InstructionsEnum.l1Translation,
Expanded(
child: InlineTooltip(
instructionsEnum: InstructionsEnum.l1Translation,
),
),
],
),
@ -182,8 +184,10 @@ class MessageTranslationCardState extends State<MessageTranslationCard> {
const Row(
mainAxisSize: MainAxisSize.min,
children: [
InlineTooltip(
instructionsEnum: InstructionsEnum.clickAgainToDeselect,
Expanded(
child: InlineTooltip(
instructionsEnum: InstructionsEnum.clickAgainToDeselect,
),
),
],
),