Skip to content

Commit

Permalink
regards #160, #161, #162, Fixes #166: Now using the proper window (`w…
Browse files Browse the repository at this point in the history
…indow` vs `msgWindow`) for all status and progress updates, and no exceptions on v115. And being extra-careful in case methods are missing. But... not really seeing the meteors have the effect they're supposed to with BetterBird 102 at least.
  • Loading branch information
eyalroz committed Jul 14, 2023
1 parent a23ac29 commit 0aa74be
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
16 changes: 12 additions & 4 deletions src/chrome/content/removedupes-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,21 @@ XPCOMUtils.defineLazyGetter(RemoveDupes, 'Prefs', () => {

RemoveDupes.StatusBar = {};

RemoveDupes.StatusBar.setStatus = function (messageWindow, statusString) {
messageWindow.statusFeedback.showStatusString(statusString);
RemoveDupes.StatusBar.statusFeedback = function (window_) {
return window_.statusFeedback ?? window_.MessageStatusFeedback;
};

RemoveDupes.StatusBar.setNamedStatus = function (messageWindow, stringName, formatArguments) {
RemoveDupes.StatusBar.showProgress = function (window_, progressFraction) {
return this.statusFeedback(window_)?.showProgress?.(progressFraction);
};

RemoveDupes.StatusBar.setStatus = function (window_, statusString) {
this.statusFeedback(window_)?.showStatusString(statusString);
};

RemoveDupes.StatusBar.setNamedStatus = function (window_, stringName, formatArguments) {
let formattedString = RemoveDupes.Strings.format(stringName, formatArguments);
RemoveDupes.StatusBar.setStatus(messageWindow, formattedString);
this.setStatus(window_, formattedString);
};

//---------------------------------------------------------
Expand Down
25 changes: 12 additions & 13 deletions src/chrome/content/removedupes.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ RemoveDupes.MessengerOverlay.originalsFolderUris = null;

RemoveDupes.MessengerOverlay.searchAndRemoveDuplicateMessages = function () {
// document.getElementById('progress-panel').removeAttribute('collapsed');
window.MsgStatusFeedback._startMeteors();
RemoveDupes.StatusBar.setNamedStatus(msgWindow, 'searching_for_dupes');
window.statusFeedback.startMeteors();
RemoveDupes.StatusBar.setNamedStatus(window, 'searching_for_dupes');

// we'll need this for some calls involving UrlListeners

Expand Down Expand Up @@ -109,8 +109,7 @@ RemoveDupes.MessengerOverlay.beginSearchForDuplicateMessages = function (searchD
RemoveDupes.MessengerOverlay.abortDupeSearch = function (searchData, labelStringName) {
window.removeEventListener("keypress", searchData.keyPressEventListener, true);
searchData = null;
window.MsgStatusFeedback._stopMeteors();
RemoveDupes.StatusBar.setNamedStatus(labelStringName);
window.statusFeedback.stopMeteors();
};

// addSearchFolders -
Expand Down Expand Up @@ -190,7 +189,7 @@ RemoveDupes.MessengerOverlay.addSearchFolders = function (folder, searchData) {
// for IMAP folders

RemoveDupes.MessengerOverlay.traverseSearchFolderSubfolders = function (folder, searchData) {
RemoveDupes.StatusBar.setNamedStatus(msgWindow, 'searching_for_dupes');
RemoveDupes.StatusBar.setNamedStatus(window, 'searching_for_dupes');

if (searchData.searchSubfolders && folder.hasSubFolders) {
for (let subFolder of folder.subFolders) {
Expand All @@ -207,7 +206,7 @@ RemoveDupes.MessengerOverlay.traverseSearchFolderSubfolders = function (folder,
// from the folders

RemoveDupes.MessengerOverlay.waitForFolderCollection = function (searchData) {
RemoveDupes.StatusBar.setNamedStatus(msgWindow, 'searching_for_dupes');
RemoveDupes.StatusBar.setNamedStatus(window, 'searching_for_dupes');

if (searchData.userAborted) {
RemoveDupes.MessengerOverlay.abortDupeSearch(searchData, 'search_aborted');
Expand Down Expand Up @@ -284,21 +283,21 @@ RemoveDupes.MessengerOverlay.processMessagesInCollectedFoldersPhase2 = function
return;
}

window.MsgStatusFeedback._stopMeteors();
window.statusFeedback.stopMeteors();
if (ObjectUtils.isEmpty(searchData.dupeSetsHashMap)) {
if (searchData.useReviewDialog) {
// if the user wants a dialog to pop up for the dupes,
// we can bother him/her with a message box for 'no dupes'
RemoveDupes.StatusBar.setStatus('');
RemoveDupes.StatusBar.setStatus(window, '');
RemoveDupes.namedAlert(window, 'no_duplicates_found');
} else {
// if the user wanted silent removal, we'll be more quiet about telling
// him/her there are no dupes
RemoveDupes.StatusBar.setNamedStatus(msgWindow, 'no_duplicates_found');
RemoveDupes.StatusBar.setNamedStatus(window, 'no_duplicates_found');
}
searchData = null;
} else {
RemoveDupes.StatusBar.setNamedStatus(msgWindow, 'search_complete');
RemoveDupes.StatusBar.setNamedStatus(window, 'search_complete');
RemoveDupes.MessengerOverlay.reviewAndRemoveDupes(searchData);
// document.getElementById('progress-panel').setAttribute('collapsed', true);
}
Expand Down Expand Up @@ -574,7 +573,7 @@ RemoveDupes.MessengerOverlay.populateDupeSetsHash = function* (searchData) {
let currentTime = (new Date()).getTime();
if (currentTime - searchData.lastStatusBarReport > searchData.reportQuantum) {
searchData.lastStatusBarReport = currentTime;
RemoveDupes.StatusBar.setNamedStatus(msgWindow, 'hashed_x_messages', [searchData.messagesHashed]);
RemoveDupes.StatusBar.setNamedStatus(window, 'hashed_x_messages', [searchData.messagesHashed]);
}
if (currentTime - searchData.lastYield > searchData.yieldQuantum) {
searchData.lastYield = currentTime;
Expand Down Expand Up @@ -634,10 +633,10 @@ RemoveDupes.MessengerOverlay.reportRefinementProgress = function (searchData, ac
return;
}
searchData.lastStatusBarReport = currentTime;
RemoveDupes.StatusBar.setNamedStatus(`refinement_status_${activity}`,
RemoveDupes.StatusBar.setNamedStatus(window, `refinement_status_${activity}`,
// We add 1 to get 1-based indices
[searchData.setsRefined + 1, searchData.totalOriginalDupeSets, messageIndex + 1, numMessages]);
window.MsgStatusFeedback.showProgress((searchData.setsRefined + 1) / searchData.totalOriginalDupeSets);
RemoveDupes.StatusBar.showProgress(window, (searchData.setsRefined + 1) / searchData.totalOriginalDupeSets);
};

// The actual second phase of message processing (see
Expand Down

0 comments on commit 0aa74be

Please sign in to comment.