Skip to content

Commit

Permalink
v1.5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
teresa-ou committed Aug 2, 2020
1 parent 73909f2 commit 415f6d4
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dist/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "inboxy: Inbox Bundles for Gmail",
"version": "1.5.3",
"version": "1.5.4",
"description": "Adds Google Inbox bundles to Gmail",
"homepage_url": "https://www.inboxymail.com",
"background": {
Expand Down
19 changes: 17 additions & 2 deletions src/bundling/Bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class Bundler {
/**
* Bundle together the messages on the current page of messages, if they aren't already bundled,
* optionally reopening the most recently open bundle.
*
* Returns an object with info for debug printing.
*/
bundleMessages(reopenRecentBundle) {
const bundledMail = this.bundledMail;
Expand All @@ -64,14 +66,18 @@ class Bundler {
: null;

if (!messageList) {
return;
return {
foundMessageList: false,
};
}

let debugInfo = { foundMessageList: true };

this.messageListWatcher.disconnect();

// Only redraw if message list isn't still bundled
if (!messageList.children[0].classList.contains('is-bundled')) {
this._bundleMessages(messageList);
debugInfo = this._bundleMessages(messageList);
messageList.children[0].classList.add('is-bundled');
}

Expand All @@ -84,13 +90,17 @@ class Bundler {
}

this.messageListWatcher.observe();

return debugInfo;
}

/**
* Bundle messages in the given messageList dom node.
*
* Table rows are reordered by using flexbox and the order property, since Gmail's js seems
* to require the DOM nodes to remain in their original order.
*
* Returns an object with info for debug printing.
*/
_bundleMessages(messageList) {
const tableBody = messageList.querySelector(Selectors.TABLE_BODY);
Expand All @@ -116,6 +126,11 @@ class Bundler {

this._applyStyles(messageNodes);
this._attachHandlers(messageNodes, messageList);

return {
numMessages: messageNodes.length,
numBundles: Object.keys(bundlesByLabel).length,
};
}

/**
Expand Down
17 changes: 16 additions & 1 deletion src/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,16 @@ import {
isStarredPage,
} from './util/MessagePageUtils';

const DEBUG = true;
const logDebugMessage = message => {
if (DEBUG) {
console.log(`inboxy-debug: ${message}`);
}
};

const html = document.querySelector('html');
if (html) {
logDebugMessage('Applying styles');
html.classList.add(InboxyClasses.INBOXY);
}

Expand Down Expand Up @@ -127,7 +135,9 @@ document.addEventListener('mousedown', e => {
//

function handleContentLoaded() {
logDebugMessage('Handle content loaded event');
const bundleCurrentPage = supportsBundling(window.location.href);
logDebugMessage(`Url: ${window.location.href}, page supports bundling: ${bundleCurrentPage}`);
tryBundling(0, bundleCurrentPage);
}

Expand All @@ -144,6 +154,8 @@ function tryBundling(i, bundleCurrentPage) {
setTimeout(() => tryBundling(i + 1, bundleCurrentPage), RETRY_TIMEOUT_MS);
}
else {
logDebugMessage('Start observers');

addPinnedToggle();
startObservers();

Expand All @@ -163,7 +175,10 @@ function tryBundling(i, bundleCurrentPage) {
setTimeout(() => tryBundling(i + 1, bundleCurrentPage), RETRY_TIMEOUT_MS);
}
else {
bundler.bundleMessages(false);
logDebugMessage('Bundle messages');

const debugInfo = bundler.bundleMessages(false);
logDebugMessage(JSON.stringify(debugInfo));
addPinnedToggle();
startObservers();
}
Expand Down

0 comments on commit 415f6d4

Please sign in to comment.