Bug 1394704
MozReview-Commit-ID: LeruZBaVNI5
--- a/browser/extensions/formautofill/content/manageDialog.js
+++ b/browser/extensions/formautofill/content/manageDialog.js
@@ -24,16 +24,17 @@ this.log = null;
FormAutofillUtils.defineLazyLogGetter(this, "manageAddresses");
class ManageRecords {
constructor(subStorageName, elements) {
this._storageInitPromise = profileStorage.initialize();
this._subStorageName = subStorageName;
this._elements = elements;
this._records = [];
+ this._timeStamp = 0;
this.prefWin = window.opener;
this.localizeDocument();
window.addEventListener("DOMContentLoaded", this, {once: true});
}
async init() {
await this.loadRecords();
this.attachEventListeners();
@@ -70,35 +71,43 @@ class ManageRecords {
}
/**
* Load records and render them.
*/
async loadRecords() {
let storage = await this.getStorage();
let records = storage.getAll();
+ let timeStamp = new Date().getTime();
+ this._timeStamp = timeStamp;
+ for (let record of records) {
+ record.label = await this.getLabel(record);
+ }
+ if (this._timeStamp > timeStamp) {
+ return;
+ }
// Sort by last modified time starting with most recent
records.sort((a, b) => b.timeLastModified - a.timeLastModified);
- await this.renderRecordElements(records);
+ this.renderRecordElements(records);
this.updateButtonsStates(this._selectedOptions.length);
// For testing only: Notify when records are loaded
this._elements.records.dispatchEvent(new CustomEvent("RecordsLoaded"));
}
/**
* Render the records onto the page while maintaining selected options if
* they still exist.
*
* @param {array<object>} records
*/
- async renderRecordElements(records) {
+ renderRecordElements(records) {
let selectedGuids = this._selectedOptions.map(option => option.value);
this.clearRecordElements();
for (let record of records) {
- let option = new Option(await this.getLabel(record),
+ let option = new Option(record.label,
record.guid,
false,
selectedGuids.includes(record.guid));
option.record = record;
this._elements.records.appendChild(option);
}
}