From 0daed986275b34287a9ef8383f500cf07b93b093 Mon Sep 17 00:00:00 2001 From: Will Hunt Date: Tue, 23 Feb 2021 12:51:17 +0000 Subject: [PATCH] Do not process an older usage event if we've already processed a newer one --- src/components/structures/LoggedInView.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/components/structures/LoggedInView.tsx b/src/components/structures/LoggedInView.tsx index c76cd7cee7..77c846d816 100644 --- a/src/components/structures/LoggedInView.tsx +++ b/src/components/structures/LoggedInView.tsx @@ -108,6 +108,7 @@ interface IState { }; }; usageLimitEventContent?: IUsageLimit; + usageLimitEventTs?: number; useCompactLayout: boolean; } @@ -339,9 +340,18 @@ class LoggedInView extends React.Component { e.getContent()['server_notice_type'] === 'm.server_notice.usage_limit_reached' ); }); + if (this.state.usageLimitEventTs > usageLimitEvent.getTs()) { + // We've processed a newer event than this one, so ignore it. + return; + } const usageLimitEventContent = usageLimitEvent && usageLimitEvent.getContent(); this._calculateServerLimitToast(this.state.syncErrorData, usageLimitEventContent); - this.setState({ usageLimitEventContent }); + this.setState({ + usageLimitEventContent, + usageLimitEventTs: usageLimitEvent.getTs(), + // This is a fresh toast, we can show toasts again + usageLimitDismissed: false, + }); }; _onPaste = (ev) => {