Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Fix filters for In App Notifications #14797

Merged
merged 2 commits into from
Feb 12, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/extensions/default/InAppNotifications/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,17 +213,28 @@ define(function (require, exports, module) {
}

function _checkExtensions(filters) {
//if no property called extensions then it's a universal notification
if (filters.extensions === undefined) {
return true;
}

var allExtensions = ExtensionManager.extensions,
allExtnsMatched = true,
userExtensionKeys = Object.keys(allExtensions).filter(function(k) {
return allExtensions[k].installInfo.locationType === 'user';
});

if (!filters.extensions) {
allExtnsMatched = userExtensionKeys.size === 0;
//if property called extensions exists but has a falsy value
//then number of user extensions must be zero
allExtnsMatched = userExtensionKeys.length === 0;
} else if (filters.extensions.length === 0) {
//if property called extensions exists but is an empty array
//then number of user extensions must greater than zero
allExtnsMatched = userExtensionKeys.length > 0;
} else {
//if property called extensions exists but is a non empty array
//then notification is targetted to users having the fitered extensions
var filteredExtns = filters.extensions,
extnIterator = null;
for (var i=0; i < filteredExtns.length; i++) {
Expand Down