Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use string literals for transaction category localized messages #10391

Merged

Conversation

Gudahtt
Copy link
Member

@Gudahtt Gudahtt commented Feb 6, 2021

We now use string literals for all transaction category localized messages. This makes it easier to verify that we have translations for each of them, and that we aren't leaving any unused translations around.

jgallegos91
jgallegos91 previously approved these changes Feb 6, 2021
Copy link

@jgallegos91 jgallegos91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea

@Gudahtt Gudahtt marked this pull request as ready for review February 7, 2021 20:40
@Gudahtt Gudahtt requested a review from a team as a code owner February 7, 2021 20:40
@metamaskbot
Copy link
Collaborator

Builds ready [b0d0613]
Page Load Metrics (1375 ± 115 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaintNaNNaNNaNNaNNaN
domContentLoaded110618721369242116
load110818741375240115
domInteractive110618711368242116

@Gudahtt Gudahtt dismissed stale reviews from ghost and jgallegos91 via cc1dc19 February 8, 2021 12:23
@Gudahtt Gudahtt force-pushed the use-string-literals-for-transaction-category-messages branch from b0d0613 to cc1dc19 Compare February 8, 2021 12:23
return defaultTitle;
}
throw new Error(
`Unrecognized transaction category: ${transactionCategory}`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe weird that we dont hit this validation if the defaultTitle is present

Copy link
Member Author

@Gudahtt Gudahtt Feb 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant the default case to imply that it was OK for the category to not be matched. That's how it's used in useTransactionDisplayData for example - there was a fallback present.

But now that you mention it... that doesn't seem ideal, I agree. Maybe we can remove the need for that fallback case. I'll look into that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was addressed in a8ab8e8

The default case has been replaced by another condition in the one case it was relied upon.

@metamaskbot
Copy link
Collaborator

Builds ready [cc1dc19]
Page Load Metrics (872 ± 20 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint6410086105
domContentLoaded7879278714120
load7889288724120
domInteractive7879278704120

We now use string literals for all transaction category localized
messages. This makes it easier to verify that we have translations for
each of them, and that we aren't leaving any unused translations around.
The default case of `getTransactionCategoryTitle` wasn't necessary. I
audited all cases where the `transactionCategory` property is assigned,
and they all assign it to known transaction categories. So it should be
impossible for that to be an unrecognized value.

The only real case the fallback was useful for was when `null` or
`undefined` was given as the transaction category in the confirm
transaction base component. That case was handled there instead.
@Gudahtt Gudahtt force-pushed the use-string-literals-for-transaction-category-messages branch from de1aa5c to a8ab8e8 Compare February 8, 2021 12:54
@metamaskbot
Copy link
Collaborator

Builds ready [a8ab8e8]
Page Load Metrics (969 ± 55 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaintNaNNaNNaNNaNNaN
domContentLoaded595115596711455
load598115896911455
domInteractive594115496611455

Copy link
Contributor

@brad-decker brad-decker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@Gudahtt Gudahtt merged commit b93046b into develop Feb 8, 2021
@Gudahtt Gudahtt deleted the use-string-literals-for-transaction-category-messages branch February 8, 2021 16:07
@github-actions github-actions bot locked and limited conversation to collaborators Feb 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants