User:Bosco/Unsigned helper.js: Difference between revisions

From Test Wiki
Content deleted Content added
findRevisionWhenTextAdded: add warning log message
PageHistoryContentSearcher: drop `findMaxIndex` – with the recent overhaul, `findMaxIndex` is unnecessary (exponentialSearch will stop on its own), and `findMaxIndex` makes searches much slower
Line 332: Line 332:
setProgressCallback(progressCallback) {
setProgressCallback(progressCallback) {
this.#progressCallback = progressCallback;
this.#progressCallback = progressCallback;
}

async #findMaxIndex() {
info('#findMaxIndex: this.#progressCallback = ', this.#progressCallback);
return exponentialSearch(0, null, 1, async (candidateIndex, progressInfo) => {
this.#progressCallback(progressInfo + ' (max search)');
const candidateRevision = await this.#contentLoader.loadRevisionId(candidateIndex);
if (candidateRevision == undefined) {
return false;
}
return true;
});
}
}


Line 366: Line 354:
}
}
}
}
const maxIndex = (startIndex === 0) ? null : (await this.#findMaxIndex());
const foundIndex = await exponentialSearch(startIndex, null, startIndex + 10, async (candidateIndex, progressInfo) => {
// const maxIndex = (await this.#findMaxIndex());
info('findRevisionWhenTextAdded: maxIndex =', maxIndex);
const foundIndex = await exponentialSearch(startIndex, maxIndex, startIndex + 10, async (candidateIndex, progressInfo) => {
try {
try {
this.#progressCallback(progressInfo);
this.#progressCallback(progressInfo);