1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-04-18 15:15:48 +02:00

Work around duplicate DM notifications and rewrite recent tweet check

This commit is contained in:
chylex 2017-08-10 00:51:38 +02:00
parent 628785c68c
commit dcaa3aab19

View File

@ -97,30 +97,30 @@
// Function: Event callback for a new tweet. // Function: Event callback for a new tweet.
// //
var onNewTweet = (function(){ var onNewTweet = (function(){
let recentMessages = new Set();
let recentTweets = new Set(); let recentTweets = new Set();
let recentTweetTimer = null; let recentTweetTimer = null;
let startRecentTweetTimer = () => { let resetRecentTweets = () => {
if (recentTweetTimer){ recentTweetTimer = null;
window.clearTimeout(recentTweetTimer); recentTweets.clear();
}
recentTweetTimer = window.setTimeout(() => {
recentTweetTimer = null;
recentTweets.clear();
}, 20000);
}; };
let checkRecentTweet = id => { let startRecentTweetTimer = () => {
if (recentTweets.size > 50){ recentTweetTimer && window.clearTimeout(recentTweetTimer);
recentTweets.clear(); recentTweetTimer = window.setTimeout(resetRecentTweets, 20000);
} };
else if (recentTweets.has(id)){
let checkTweetCache = (set, id) => {
if (set.has(id)){
return true; return true;
} }
recentTweets.add(id); if (set.size > 50){
startRecentTweetTimer(); set.clear();
}
set.add(id);
return false; return false;
}; };
@ -129,10 +129,17 @@
}; };
return function(column, tweet){ return function(column, tweet){
if (checkRecentTweet(tweet.id)){ if (tweet instanceof TD.services.TwitterConversation){
if (checkTweetCache(recentMessages, tweet.id)){
return;
}
}
else if (checkTweetCache(recentTweets, tweet.id)){
return; return;
} }
startRecentTweetTimer();
if (column.model.getHasNotification()){ if (column.model.getHasNotification()){
let previews = $TDX.notificationMediaPreviews; let previews = $TDX.notificationMediaPreviews;