| Left: | ||
| Right: |
| LEFT | RIGHT |
|---|---|
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-present eyeo GmbH | 3 * Copyright (C) 2006-present eyeo GmbH |
| 4 * | 4 * |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
| 7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
| 8 * | 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
| 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| 16 */ | 16 */ |
| 17 | 17 |
| 18 /* global togglePref */ | 18 /* global setPref */ |
|
Sebastian Noack
2017/10/08 19:17:22
As I already told Manish on a different review, I'
kzar
2017/10/09 10:33:25
Acknowledged.
| |
| 19 | 19 |
| 20 "use strict"; | 20 "use strict"; |
| 21 | 21 |
| 22 function getDocLinks(notification) | 22 function getDocLinks(notification) |
| 23 { | 23 { |
| 24 let docLinks = []; | |
|
Manish Jethani
2017/10/08 22:31:34
The variable is unnecessary here.
kzar
2017/10/09 10:33:25
Sure, we could return an empty array if notificati
Manish Jethani
2017/10/09 10:54:12
I must be looking at the wrong diff, because to me
kzar
2017/10/09 15:10:54
Oh yea, you are right sorry. I switched to mapping
| |
| 25 | |
| 26 if (!notification.links) | 24 if (!notification.links) |
| 27 return Promise.resolve(docLinks); | 25 return Promise.resolve([]); |
| 28 | 26 |
| 29 return Promise.all( | 27 return Promise.all( |
| 30 notification.links.map(link => | 28 notification.links.map(link => |
| 31 { | 29 { |
| 32 return new Promise((resolve, reject) => | 30 return new Promise((resolve, reject) => |
|
Manish Jethani
2017/10/08 22:31:34
If you prefer it, you could lose the braces and th
kzar
2017/10/09 10:33:25
Yea I considered that, but I figured it looked nic
Manish Jethani
2017/10/09 10:54:12
Acknowledged.
| |
| 33 { | 31 { |
| 34 chrome.runtime.sendMessage({ | 32 chrome.runtime.sendMessage({ |
| 35 type: "app.get", | 33 type: "app.get", |
| 36 what: "doclink", | 34 what: "doclink", |
| 37 link | 35 link |
| 38 }, resolve); | 36 }, resolve); |
| 39 }); | 37 }); |
| 40 }) | 38 }) |
| 41 ); | 39 ); |
| 42 } | 40 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 87 | 85 |
| 88 messageElement.addEventListener("click", event => | 86 messageElement.addEventListener("click", event => |
| 89 { | 87 { |
| 90 let link = event.target; | 88 let link = event.target; |
| 91 while (link && link != messageElement && link.localName != "a") | 89 while (link && link != messageElement && link.localName != "a") |
| 92 link = link.parentNode; | 90 link = link.parentNode; |
| 93 if (!link) | 91 if (!link) |
| 94 return; | 92 return; |
| 95 event.preventDefault(); | 93 event.preventDefault(); |
| 96 event.stopPropagation(); | 94 event.stopPropagation(); |
| 97 ext.pages.open(link.href); | 95 chrome.tabs.create({url: link.href}); |
| 98 }); | 96 }); |
| 99 }); | 97 }); |
| 100 | 98 |
| 101 let notificationElement = document.getElementById("notification"); | 99 let notificationElement = document.getElementById("notification"); |
| 102 notificationElement.className = notification.type; | 100 notificationElement.className = notification.type; |
| 103 notificationElement.hidden = false; | 101 notificationElement.hidden = false; |
| 104 notificationElement.addEventListener("click", event => | 102 notificationElement.addEventListener("click", event => |
| 105 { | 103 { |
| 106 if (event.target.id == "notification-close") | 104 if (event.target.id == "notification-close") |
| 107 notificationElement.classList.add("closing"); | 105 notificationElement.classList.add("closing"); |
| 108 else if (event.target.id == "notification-optout" || | 106 else if (event.target.id == "notification-optout" || |
| 109 event.target.id == "notification-hide") | 107 event.target.id == "notification-hide") |
| 110 { | 108 { |
| 111 if (event.target.id == "notification-optout") | 109 if (event.target.id == "notification-optout") |
| 112 togglePref("notifications_ignoredcategories"); | 110 setPref("notifications_ignoredcategories", true); |
|
Manish Jethani
2017/10/08 22:31:34
The "prefs.toggle" implementation in messageRespon
Manish Jethani
2017/10/08 22:40:59
Since we're adding "notifications.get", we could a
kzar
2017/10/09 10:33:25
Well my understanding was the option would be togg
Manish Jethani
2017/10/09 10:54:12
The reason the original code was passing true as t
Manish Jethani
2017/10/09 11:53:52
Looking at this code in adblockpluscore lib/notifi
kzar
2017/10/09 15:10:54
Done.
| |
| 113 | 111 |
| 114 notificationElement.hidden = true; | 112 notificationElement.hidden = true; |
| 115 notification.onClicked(); | 113 notification.onClicked(); |
| 116 } | 114 } |
| 117 }, true); | 115 }, true); |
| 118 }); | 116 }); |
| 119 }, false); | 117 }, false); |
| LEFT | RIGHT |