From b8b26d3e7935dc1e5b87bcc82771cdd30cf45afc Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg <scott@nonnenberg.com> Date: Mon, 27 Nov 2017 15:44:44 -0800 Subject: [PATCH] On group/contact import: don't re-add hidden entries to left pane (#1811) * On contact import: don't re-add hidden contacts to left pane * On group import: don't re-add hidden groups to left pane --- js/background.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/js/background.js b/js/background.js index e22cdcc7c..3bdabdc89 100644 --- a/js/background.js +++ b/js/background.js @@ -367,6 +367,14 @@ return ConversationController.getOrCreateAndWait(id, 'private') .then(function(conversation) { return new Promise(function(resolve, reject) { + var activeAt = conversation.get('active_at'); + + // The idea is to make any new contact show up in the left pane. If + // activeAt is null, then this contact has been purposefully hidden. + if (activeAt !== null) { + activeAt = activeAt || Date.now(); + } + if (details.profileKey) { conversation.set({profileKey: details.profileKey}); } @@ -374,7 +382,7 @@ name: details.name, avatar: details.avatar, color: details.color, - active_at: conversation.get('active_at') || Date.now(), + active_at: activeAt, }).then(resolve, reject); }).then(function() { if (details.verified) { @@ -411,7 +419,13 @@ type: 'group', }; if (details.active) { - updates.active_at = Date.now(); + var activeAt = conversation.get('active_at'); + + // The idea is to make any new group show up in the left pane. If + // activeAt is null, then this group has been purposefully hidden. + if (activeAt !== null) { + updates.active_at = activeAt || Date.now(); + } } else { updates.left = true; }