Skip to content

Commit

Permalink
fix import line conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
lilydu committed Jan 6, 2025
2 parents 29e00e9 + 87232fa commit b034e6a
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions dotnet/packages/Microsoft.TeamsAI/Microsoft.TeamsAI/TypingTimer.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Microsoft.Teams.AI.Utilities;
using Microsoft.Bot.Schema;
using Microsoft.Bot.Builder;
using Microsoft.Identity.Client;
using Microsoft.Teams.AI.Application;

namespace Microsoft.Teams.AI
Expand All @@ -21,6 +22,11 @@ internal class TypingTimer : IDisposable
/// </summary>
private bool _disposedValue = false;

/// <summary>
/// The send "typing" activity task
/// </summary>
private Task _lastSend = Task.CompletedTask;

/// <summary>
/// Constructs a new instance of the <see cref="TypingTimer"/> class.
/// </summary>
Expand Down Expand Up @@ -101,7 +107,8 @@ private async void SendTypingActivity(object state)

try
{
await turnContext.SendActivityAsync(new Activity { Type = ActivityTypes.Typing });
_lastSend = turnContext.SendActivityAsync(new Activity { Type = ActivityTypes.Typing });
await _lastSend;
if (IsRunning())
{
_timer?.Change(_interval, Timeout.Infinite);
Expand All @@ -116,21 +123,22 @@ private async void SendTypingActivity(object state)
}
}

private Task<ResourceResponse[]> StopTimerWhenSendMessageActivityHandlerAsync(ITurnContext turnContext, List<Activity> activities, Func<Task<ResourceResponse[]>> next)
private async Task<ResourceResponse[]> StopTimerWhenSendMessageActivityHandlerAsync(ITurnContext turnContext, List<Activity> activities, Func<Task<ResourceResponse[]>> next)
{
if (_timer != null)
{
foreach (Activity activity in activities)
{
if (activity.Type == ActivityTypes.Message || activity.GetChannelData<StreamingChannelData>()?.StreamType != null)
{
await _lastSend;
Dispose();
break;
}
}
}

return next();
return await next();
}
}
}

0 comments on commit b034e6a

Please sign in to comment.