[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor-browser] 09/37: Bug 1771026 - Remove some dead tagging code in Pocket panels. r=Gijs, a=RyanVM



This is an automated email from the git hooks/post-receive script.

richard pushed a commit to branch tor-browser-91.11.0esr-11.5-1
in repository tor-browser.

commit 5dd6888c8df52f707106cb51e1a2998b3f4a97f6
Author: Scott <scott.downe@xxxxxxxxx>
AuthorDate: Fri May 27 21:13:52 2022 +0000

    Bug 1771026 - Remove some dead tagging code in Pocket panels. r=Gijs, a=RyanVM
    
    Differential Revision: https://phabricator.services.mozilla.com/D147426
---
 browser/components/pocket/content/pktApi.jsm       | 62 ++--------------------
 .../test/unit/browser_pocket_AboutPocketParent.js  |  2 +-
 2 files changed, 5 insertions(+), 59 deletions(-)

diff --git a/browser/components/pocket/content/pktApi.jsm b/browser/components/pocket/content/pktApi.jsm
index 14a125974180d..7c1ddaaa996ad 100644
--- a/browser/components/pocket/content/pktApi.jsm
+++ b/browser/components/pocket/content/pktApi.jsm
@@ -331,6 +331,10 @@ var pktApi = (function() {
     setSetting("premium_status", undefined);
     setSetting("latestSince", undefined);
     setSetting("tags", undefined);
+    // An old pref that is no longer used,
+    // but the user data may still exist on some profiles.
+    // So best to clean it up just in case.
+    // Can probably remove this line in the future.
     setSetting("usedTags", undefined);
 
     setSetting("fsv1", undefined);
@@ -582,32 +586,6 @@ var pktApi = (function() {
     };
     action = extend(action, actionPart);
 
-    // Backup the success callback as we need it later
-    var finalSuccessCallback = options.success;
-
-    // Switch the success callback
-    options.success = function(data) {
-      // Update used tags
-      var usedTagsJSON = getSetting("usedTags");
-      var usedTags = usedTagsJSON ? JSON.parse(usedTagsJSON) : {};
-
-      // Check for each tag if it's already in the used tags
-      for (var i = 0; i < tags.length; i++) {
-        var tagToSave = tags[i].trim();
-        var newUsedTagObject = {
-          tag: tagToSave,
-          timestamp: new Date().getTime(),
-        };
-        usedTags[tagToSave] = newUsedTagObject;
-      }
-      setSetting("usedTags", JSON.stringify(usedTags));
-
-      // Let the callback know that we are finished
-      if (finalSuccessCallback) {
-        finalSuccessCallback(data);
-      }
-    };
-
     // Execute the action
     return sendAction(action, options);
   }
@@ -624,40 +602,8 @@ var pktApi = (function() {
       return [];
     };
 
-    var sortedUsedTagsFromSettings = function() {
-      // Get and Sort used tags
-      var usedTags = [];
-
-      var usedTagsJSON = getSetting("usedTags");
-      if (typeof usedTagsJSON !== "undefined") {
-        var usedTagsObject = JSON.parse(usedTagsJSON);
-        var usedTagsObjectArray = [];
-        for (var tagKey in usedTagsObject) {
-          usedTagsObjectArray.push(usedTagsObject[tagKey]);
-        }
-
-        // Sort usedTagsObjectArray based on timestamp
-        usedTagsObjectArray.sort(function(usedTagA, usedTagB) {
-          var a = usedTagA.timestamp;
-          var b = usedTagB.timestamp;
-          return a - b;
-        });
-
-        // Get all keys tags
-        for (var j = 0; j < usedTagsObjectArray.length; j++) {
-          usedTags.push(usedTagsObjectArray[j].tag);
-        }
-
-        // Reverse to set the last recent used tags to the front
-        usedTags.reverse();
-      }
-
-      return usedTags;
-    };
-
     return {
       tags: tagsFromSettings(),
-      usedTags: sortedUsedTagsFromSettings(),
     };
   }
 
diff --git a/browser/components/pocket/test/unit/browser_pocket_AboutPocketParent.js b/browser/components/pocket/test/unit/browser_pocket_AboutPocketParent.js
index 4084324116f5c..429d3fc55fc7f 100644
--- a/browser/components/pocket/test/unit/browser_pocket_AboutPocketParent.js
+++ b/browser/components/pocket/test/unit/browser_pocket_AboutPocketParent.js
@@ -251,7 +251,7 @@ test_runner(async function test_AboutPocketParent_receiveMessage_PKT_getTags({
   );
   Assert.deepEqual(
     sendResponseMessageToPanel.firstCall.args,
-    ["PKT_getTags", 1, { tags: [], usedTags: [] }],
+    ["PKT_getTags", 1, { tags: [] }],
     "Should fire sendResponseMessageToPanel with proper args from PKT_getTags"
   );
 });

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits