Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion recipes/msteams/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "msteams",
"name": "Microsoft Teams",
"version": "3.3.2",
"version": "3.3.3",
"license": "MIT",
"aliases": [
"teamsChat"
Expand Down
39 changes: 30 additions & 9 deletions recipes/msteams/webview.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,15 @@ function _interopRequireDefault(obj) {

const _path = _interopRequireDefault(require('path'));

// Variable to keep previous notification in
let previousNotification = null;

module.exports = Ferdium => {
const getMessages = () => {
let messages = 0;

const isTeamsV2 = window.location.href.includes('/v2/');

let badges = document.querySelectorAll(
const badges = document.querySelectorAll(
'.activity-badge.dot-activity-badge .activity-badge',
);

if (isTeamsV2) {
badges = document.querySelectorAll('.fui-Badge');
}

if (badges) {
Array.prototype.forEach.call(badges, badge => {
messages += Ferdium.safeParseInt(badge.textContent);
Expand All @@ -38,4 +33,30 @@ module.exports = Ferdium => {

Ferdium.injectCSS(_path.default.join(__dirname, 'service.css'));
Ferdium.injectJSUnsafe(_path.default.join(__dirname, 'webview-unsafe.js'));

// Function to handle the double notifications
Ferdium.onNotify(notification => {
// Turn off the need for clicking on the notification, for it to disappear
notification.options.requireInteraction = false;

if (previousNotification === null) {
// Handle very first notification
previousNotification = notification;

return notification;
}

// Updating the previous notification variable
previousNotification = notification;

if (
previousNotification.title === notification.title
&& previousNotification.options.body === notification.options.body
) {
// The notification is the same as previous one, so we return null to ensure that it will not show
return null;
}

return notification;
});
};
Loading