From 9c4753f4d655870d7c04ff2374b18804c1e62aca Mon Sep 17 00:00:00 2001 From: Ursula Sarracini Date: Fri, 16 Feb 2018 11:38:37 -0500 Subject: [PATCH] Bug 1438658 - Allow pktApi.jsm to archive an item r=Mardak MozReview-Commit-ID: JoTzYy84ZI5 --HG-- extra : rebase_source : ef4f11f414b4c2bd551d3c62ee165ca1d89795e8 --- browser/extensions/pocket/content/pktApi.jsm | 17 +++++++++++++++++ toolkit/modules/NewTabUtils.jsm | 13 +++++++++++++ 2 files changed, 30 insertions(+) diff --git a/browser/extensions/pocket/content/pktApi.jsm b/browser/extensions/pocket/content/pktApi.jsm index 86b17de97c8e..d3ca7af0c1ba 100644 --- a/browser/extensions/pocket/content/pktApi.jsm +++ b/browser/extensions/pocket/content/pktApi.jsm @@ -384,6 +384,22 @@ var pktApi = (function() { return sendAction(action, options); } + /** + * Archive an item identified by item id from the users list + * @param {string} itemId The id from the item we want to archive + * @param {Object | undefined} options Can provide an actionInfo object with + * further data to send to the API. Can + * have success and error callbacks + * @return {Boolean} Returns Boolean whether the api call started sucessfully + */ + function archiveItem(itemId, options) { + var action = { + action: "archive", + item_id: itemId + }; + return sendAction(action, options); + } + /** * General function to send all kinds of actions like adding of links or * removing of items via the API @@ -652,6 +668,7 @@ var pktApi = (function() { clearUserData, addLink, deleteItem, + archiveItem, addTagsToItem, addTagsToURL, getTags, diff --git a/toolkit/modules/NewTabUtils.jsm b/toolkit/modules/NewTabUtils.jsm index b5c8ba6feb94..65bcaf2b2445 100644 --- a/toolkit/modules/NewTabUtils.jsm +++ b/toolkit/modules/NewTabUtils.jsm @@ -1379,6 +1379,19 @@ var ActivityStreamLinks = { return new Promise((success, error) => pktApi.deleteItem(aItemID, {success, error})); }, + /** + * Helper function which makes the call to the Pocket API to archive an item from + * a user's saved to Pocket feed. + * + * @param {Integer} aItemID + * The unique pocket ID used to find the item to be archived + * + *@returns {Promise} Returns a promise at completion + */ + archivePocketEntry(aItemID) { + return new Promise((success, error) => pktApi.archiveItem(aItemID, {success, error})); + }, + /** * Get the Highlights links to show on Activity Stream *