Skip to content
This repository was archived by the owner on Feb 21, 2021. It is now read-only.

Commit 45326f7

Browse files
committed
Refs #264 - Provide environment information when opening newtab notifications
1 parent f43ff58 commit 45326f7

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

lib/notificationHelper.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ const displayMethods = new Map([
3636
]);
3737
const defaultDisplayMethods = ["popup"];
3838

39+
const linkPlaceholders = new Set([
40+
["LANG", () => browser.i18n.getUILanguage().replace("-", "_")],
41+
["ADDON_NAME", () => info.addonName],
42+
["ADDON_VERSION", () => info.addonVersion],
43+
["APPLICATION_NAME", () => info.application],
44+
["APPLICATION_VERSION", () => info.applicationVersion],
45+
["PLATFORM_NAME", () => info.platform],
46+
["PLATFORM_VERSION", () => info.platformVersion]
47+
]);
48+
3949
// We must hard code any "abp:" prefixed notification links here, otherwise
4050
// notifications linking to them will not be displayed at all.
4151
const localNotificationPages = new Map([
@@ -224,10 +234,14 @@ function notificationDismissed(notificationId, stashedInNotificationCenter)
224234

225235
function openNotificationInNewTab(notification)
226236
{
237+
let [url] = notification.links;
238+
for (let [key, getValue] of linkPlaceholders)
239+
url = url.replace(`%${key}%`, encodeURIComponent(getValue()));
240+
227241
let onTabCreated = () =>
228242
{
229243
browser.tabs.onCreated.removeListener(onTabCreated);
230-
browser.tabs.create({url: notification.links[0]});
244+
browser.tabs.create({url});
231245
notifications.markAsShown(notification.id);
232246
};
233247

0 commit comments

Comments
 (0)