This update improves the throttling mechanism for conversation meta requests to optimize server load and enhance performance. The changes implement differentiated thresholds based on account size - a 2-second throttle for small accounts (≤100 conversations) and a 10-second throttle for large accounts (>100 conversations). Fixes #11178
30 lines
579 B
JavaScript
30 lines
579 B
JavaScript
class ConversationMetaThrottleManager {
|
|
constructor() {
|
|
this.lastUpdatedTime = null;
|
|
}
|
|
|
|
shouldThrottle(threshold = 10000) {
|
|
if (!this.lastUpdatedTime) {
|
|
return false;
|
|
}
|
|
|
|
const currentTime = new Date().getTime();
|
|
const lastUpdatedTime = new Date(this.lastUpdatedTime).getTime();
|
|
|
|
if (currentTime - lastUpdatedTime < threshold) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
markUpdate() {
|
|
this.lastUpdatedTime = new Date();
|
|
}
|
|
|
|
reset() {
|
|
this.lastUpdatedTime = null;
|
|
}
|
|
}
|
|
|
|
export default new ConversationMetaThrottleManager();
|