From 28d2f0b66e2be19345f1a09e871fcd107d15e0d5 Mon Sep 17 00:00:00 2001 From: gorhill Date: Wed, 29 Nov 2017 14:40:18 -0500 Subject: [PATCH] fix #852 --- src/js/background.js | 2 ++ src/js/messaging.js | 2 ++ src/js/popup.js | 12 ++++++------ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/js/background.js b/src/js/background.js index a9ba8fa..c79d52a 100644 --- a/src/js/background.js +++ b/src/js/background.js @@ -117,6 +117,8 @@ return { externalHostsFiles: '', iconBadgeEnabled: false, maxLoggedRequests: 1000, + popupCollapseAllDomains: false, + popupCollapseBlacklistedDomains: false, popupScopeLevel: 'domain', processHyperlinkAuditing: true, processReferer: false, diff --git a/src/js/messaging.js b/src/js/messaging.js index 04d1018..1323bd1 100644 --- a/src/js/messaging.js +++ b/src/js/messaging.js @@ -146,6 +146,8 @@ var matrixSnapshot = function(pageStore, details) { var r = { appVersion: vAPI.app.version, blockedCount: pageStore.requestStats.blocked.all, + collapseAllDomains: µmuser.popupCollapseAllDomains, + collapseBlacklistedDomains: µmuser.popupCollapseBlacklistedDomains, diff: [], domain: pageStore.pageDomain, headerIndices: Array.from(headerIndices), diff --git a/src/js/popup.js b/src/js/popup.js index 49151c3..a6faab5 100644 --- a/src/js/popup.js +++ b/src/js/popup.js @@ -373,7 +373,7 @@ function getCollapseState(domain) { if ( typeof states === 'object' && states[domain] !== undefined ) { return states[domain]; } - return getUISetting('popupCollapseDomains') === true; + return matrixSnapshot.collapseAllDomains === true; } function toggleCollapseState(elem) { @@ -388,7 +388,7 @@ function toggleMainCollapseState(uelem) { var matHead = uelem.ancestors('#matHead.collapsible').toggleClass('collapsed'); var collapsed = matHead.hasClass('collapsed'); uDom('#matList .matSection.collapsible').toggleClass('collapsed', collapsed); - setUISetting('popupCollapseDomains', collapsed); + setUserSetting('popupCollapseAllDomains', collapsed); var specificCollapseStates = getUISetting('popupCollapseSpecificDomains') || {}; var domains = Object.keys(specificCollapseStates); @@ -409,7 +409,7 @@ function toggleSpecificCollapseState(uelem) { var section = uelem.ancestors('.matSection.collapsible').toggleClass('collapsed'), domain = expandosFromNode(section).domain, collapsed = section.hasClass('collapsed'), - mainCollapseState = getUISetting('popupCollapseDomains') === true, + mainCollapseState = matrixSnapshot.collapseAllDomains === true, specificCollapseStates = getUISetting('popupCollapseSpecificDomains') || {}; if ( collapsed !== mainCollapseState ) { specificCollapseStates[domain] = collapsed; @@ -605,7 +605,7 @@ var createMatrixRow = function() { function renderMatrixHeaderRow() { var matHead = uDom('#matHead.collapsible'); - matHead.toggleClass('collapsed', getUISetting('popupCollapseDomains') === true); + matHead.toggleClass('collapsed', matrixSnapshot.collapseAllDomains === true); var cells = matHead.descendants('.matCell'), cell, expandos; cell = cells.nodeAt(0); expandos = expandosFromNode(cell); @@ -1033,7 +1033,7 @@ function makeMatrixGroup4(group) { var groupDiv = createMatrixGroup().addClass('g4'); createMatrixSection() .addClass('g4Meta') - .toggleClass('g4Collapsed', !!getUISetting('popupHideBlacklisted')) + .toggleClass('g4Collapsed', !!matrixSnapshot.collapseBlacklistedDomains) .appendTo(groupDiv); makeMatrixMetaRow(computeMatrixGroupMetaStats(group), 'g4') .appendTo(groupDiv); @@ -1518,7 +1518,7 @@ uDom('#matList').on('click', '.g4Meta', function() { var collapsed = uDom(this) .toggleClass('g4Collapsed') .hasClass('g4Collapsed'); - setUISetting('popupHideBlacklisted', collapsed); + setUserSetting('popupCollapseBlacklistedDomains', collapsed); }); /******************************************************************************/