mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 20:05:49 +00:00
Bug 1227743 - Remove snippet (id) from rotation after the user clicks on it. r=mfinkle
MozReview-Commit-ID: 10m8yssL94U --HG-- extra : rebase_source : d37e115d26f25d398c72c2c59455c933172280c4 extra : amend_source : 8ba89625c0c388f399104537cb05bc9aac5fe426 extra : histedit_source : e151e20f5a18f78bda7d01b11f2f2cc0bb77ab16%2Ca17440ac9be6318574d08de92bb0368d021e3b03
This commit is contained in:
parent
9249c82407
commit
0b943c2a8b
@ -204,12 +204,11 @@ function updateBanner(messages) {
|
||||
weight: message.weight,
|
||||
onclick: function() {
|
||||
gChromeWin.BrowserApp.loadURI(message.url);
|
||||
removeSnippet(id, message.id);
|
||||
UITelemetry.addEvent("action.1", "banner", null, message.id);
|
||||
},
|
||||
ondismiss: function() {
|
||||
// Remove this snippet from the banner, and store its id so we'll never show it again.
|
||||
Home.banner.remove(id);
|
||||
removeSnippet(message.id);
|
||||
removeSnippet(id, message.id);
|
||||
UITelemetry.addEvent("cancel.1", "banner", null, message.id);
|
||||
},
|
||||
onshown: function() {
|
||||
@ -225,11 +224,19 @@ function updateBanner(messages) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends snippet id to the end of `snippets-removed.txt`
|
||||
* Removes a snippet message from the home banner rotation, and stores its
|
||||
* snippet id in a pref so we'll never show it again.
|
||||
*
|
||||
* @param messageId unique id for home banner message, returned from Home.banner API
|
||||
* @param snippetId unique id for snippet, sent from snippets server
|
||||
*/
|
||||
function removeSnippet(snippetId) {
|
||||
function removeSnippet(messageId, snippetId) {
|
||||
// Remove the message from the home banner rotation.
|
||||
Home.banner.remove(messageId);
|
||||
|
||||
// Remove the message from the stored message ids.
|
||||
gMessageIds.splice(gMessageIds.indexOf(messageId), 1);
|
||||
|
||||
let removedSnippetIds;
|
||||
try {
|
||||
removedSnippetIds = JSON.parse(Services.prefs.getCharPref(SNIPPETS_REMOVED_IDS_PREF));
|
||||
|
Loading…
Reference in New Issue
Block a user