1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-05-01 17:34:10 +02:00

Fix multiple notifications showing for the same tweet in multiple columns

This commit is contained in:
chylex 2017-05-16 17:15:02 +02:00
parent 5c7eb0535d
commit 39ae9b8ba0

View File

@ -80,7 +80,39 @@
//
// Function: Event callback for a new tweet.
//
var onNewTweet = function(column, tweet){
var onNewTweet = (function(){
let recentTweets = new Set();
let recentTweetTimer = null;
let startRecentTweetTimer = () => {
if (recentTweetTimer){
window.clearTimeout(recentTweetTimer);
}
recentTweetTimer = window.setTimeout(() => {
recentTweetTimer = null;
recentTweets.clear();
}, 10000);
};
let checkRecentTweet = id => {
if (recentTweets.size > 50){
recentTweets.clear();
}
else if (recentTweets.has(id)){
return true;
}
recentTweets.add(id);
startRecentTweetTimer();
return false;
};
return function(column, tweet){
if (checkRecentTweet(tweet.id)){
return;
}
if (column.model.getHasNotification()){
let html = $(tweet.render({
withFooter: false,
@ -117,6 +149,7 @@
$TD.onTweetSound();
}
};
})();
//
// Function: Retrieves the tags to be put into <head> for notification HTML code.