Do not process an older usage event if we've already processed a newer one

pull/21833/head
Will Hunt 2021-02-23 12:51:17 +00:00
parent 72ff919512
commit 0daed98627
1 changed files with 11 additions and 1 deletions

View File

@ -108,6 +108,7 @@ interface IState {
}; };
}; };
usageLimitEventContent?: IUsageLimit; usageLimitEventContent?: IUsageLimit;
usageLimitEventTs?: number;
useCompactLayout: boolean; useCompactLayout: boolean;
} }
@ -339,9 +340,18 @@ class LoggedInView extends React.Component<IProps, IState> {
e.getContent()['server_notice_type'] === 'm.server_notice.usage_limit_reached' 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(); const usageLimitEventContent = usageLimitEvent && usageLimitEvent.getContent();
this._calculateServerLimitToast(this.state.syncErrorData, usageLimitEventContent); 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) => { _onPaste = (ev) => {