Both UI timer and database timer will remove expired message

This commit is contained in:
Scott Nonnenberg 2018-08-09 16:18:10 -07:00
parent 9f920aa35b
commit 37f3054976
4 changed files with 26 additions and 6 deletions

View file

@ -81,6 +81,7 @@ export interface Props {
referencedMessageNotFound: boolean;
};
authorAvatarPath?: string;
isExpired: boolean;
expirationLength?: number;
expirationTimestamp?: number;
onClickAttachment?: () => void;
@ -211,15 +212,22 @@ export class Message extends React.Component<Props, State> {
}
}
public componentDidUpdate() {
this.checkExpired();
}
public checkExpired() {
const now = Date.now();
const { expirationTimestamp, expirationLength } = this.props;
const { isExpired, expirationTimestamp, expirationLength } = this.props;
if (!expirationTimestamp || !expirationLength) {
return;
}
if (this.expiredTimeout) {
return;
}
if (now >= expirationTimestamp) {
if (isExpired || now >= expirationTimestamp) {
this.setState({
expiring: true,
});