Skip to content

Commit

Permalink
refactor: break up calculateExpiryPercentage func
Browse files Browse the repository at this point in the history
  • Loading branch information
vyneer committed Jul 26, 2024
1 parent 9f36223 commit e937126
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions assets/chat/js/menus/ChatEventBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,11 @@ export default class ChatEventBar {
* @private
*/
calculateExpiryPercentage(event) {
return (
((event.expirationTimestamp - Date.now()) * 100) /
(event.expirationTimestamp - event.timestamp)
);
const currentTimestamp = Date.now();
const eventTimeLeft = event.expirationTimestamp - currentTimestamp;
const eventFullDuration = event.expirationTimestamp - event.timestamp;

return (eventTimeLeft * 100) / eventFullDuration;
}

/**
Expand Down

0 comments on commit e937126

Please sign in to comment.