Skip to content

Commit

Permalink
Reduce code duplication for expiration times
Browse files Browse the repository at this point in the history
  • Loading branch information
ButterscotchV committed Jan 29, 2024
1 parent 5ae2ab2 commit 04df123
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions ButterSTT/MessageSystem/MessageQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ public void QueueParagraphToFit(int padding = 0)
}
}

private static DateTime ComputeExpiration(TimeSpan span) =>
span >= TimeSpan.MaxValue ? DateTime.MaxValue : DateTime.UtcNow + span;

private void ProgressWordQueue()
{
// Make sure there is enough room to fit a new word in the message,
Expand All @@ -136,12 +139,8 @@ private void ProgressWordQueue()
MessageWordQueue.Enqueue(
new MessageWord(
word,
WordTime >= TimeSpan.MaxValue
? DateTime.MaxValue
: DateTime.UtcNow + WordTime,
HardWordTime >= TimeSpan.MaxValue
? DateTime.MaxValue
: DateTime.UtcNow + HardWordTime
ComputeExpiration(WordTime),
ComputeExpiration(HardWordTime)
)
);
CurMessageLength += word.Length;
Expand Down

0 comments on commit 04df123

Please sign in to comment.