[L10n] Don't try to connect the root element when it has already been done

In Firefox debug builds, there is an assertion to check that we don't connect
a subelement of an already connected root. Thanks to this assertion, we can see
that the root has already been added to Fluent, hence we don't need to do it
a second time.
We don't need to await anymore on the translation in order to update the
toolbar: it'll be done by Fluent, so we can safely remove the "localized"
event and avoid to wait for it.
This commit is contained in:
Calixte Denizet 2023-10-19 18:00:16 +02:00
parent c60401a765
commit a0b9c937ae
2 changed files with 6 additions and 19 deletions

View file

@ -46,8 +46,6 @@ const PAGE_NUMBER_LOADING_INDICATOR = "visiblePageIsLoading";
*/
class Toolbar {
#wasLocalized = false;
/**
* @param {ToolbarOptions} options
* @param {EventBus} eventBus
@ -206,11 +204,6 @@ class Toolbar {
// Suppress context menus for some controls.
scaleSelect.oncontextmenu = noContextMenu;
this.eventBus._on("localized", () => {
this.#wasLocalized = true;
this.#updateUIState(true);
});
this.#bindEditorToolsListener(options);
}
@ -254,10 +247,6 @@ class Toolbar {
}
#updateUIState(resetNumPages = false) {
if (!this.#wasLocalized) {
// Don't update the UI state until we localize the toolbar.
return;
}
const { pageNumber, pagesCount, pageScaleValue, pageScale, items } = this;
if (resetNumPages) {