Bug 1928738: Change the localized name of the default profile. r=niklas,fluent-reviewers,flod

Differential Revision: https://phabricator.services.mozilla.com/D227759
This commit is contained in:
Jared Hirsch
2024-11-09 03:02:38 +00:00
parent 9d1167a19e
commit a88a8a7c29
2 changed files with 15 additions and 6 deletions

View File

@@ -858,18 +858,24 @@ class SelectableProfileServiceClass {
* @returns {SelectableProfile} The newly created profile object.
*/
async #createProfile(existingProfilePath) {
let nextProfileNumber =
1 + Math.max(0, ...(await this.getAllProfiles()).map(p => p.id));
let [defaultName] = lazy.profilesLocalization.formatMessagesSync([
{ id: "default-profile-name", args: { number: nextProfileNumber } },
]);
let nextProfileNumber = Math.max(
0,
...(await this.getAllProfiles()).map(p => p.id)
);
let [defaultName, originalName] =
lazy.profilesLocalization.formatMessagesSync([
{ id: "default-profile-name", args: { number: nextProfileNumber } },
{ id: "original-profile-name" },
]);
let window = Services.wm.getMostRecentBrowserWindow();
let isDark = window?.matchMedia("(-moz-system-dark-theme)").matches;
let randomIndex = Math.floor(Math.random() * this.#defaultAvatars.length);
let profileData = {
name: defaultName.value,
// The original toolkit profile is added first and is assigned a
// different name.
name: nextProfileNumber == 0 ? originalName.value : defaultName.value,
avatar: this.#defaultAvatars[randomIndex],
themeId: "default-theme@mozilla.org",
themeFg: isDark ? "rgb(255,255,255)" : "rgb(21,20,26)",