Skip to content

Commit 389eb54

Browse files
committed
Add option to delete poll
1 parent 79da1e7 commit 389eb54

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

Assets/Plugins/StreamChat/Core/IStreamPollsApi.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ public interface IStreamPollsApi
3030
/// <param name="queryRequest">Request with query filters and parameters</param>
3131
/// <returns>List of polls matching the query</returns>
3232
Task<IEnumerable<IStreamPoll>> QueryPollsAsync(StreamQueryPollsRequest queryRequest);
33+
34+
/// <summary>
35+
/// Delete a poll by ID
36+
/// </summary>
37+
/// <param name="pollId">The poll ID to delete</param>
38+
Task DeletePollAsync(string pollId);
3339
}
3440
}
3541

Assets/Plugins/StreamChat/Core/StreamPollsApi.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,19 @@ public async Task<IEnumerable<IStreamPoll>> QueryPollsAsync(StreamQueryPollsRequ
5656
return result;
5757
}
5858

59+
public async Task DeletePollAsync(string pollId)
60+
{
61+
StreamAsserts.AssertNotNullOrEmpty(pollId, nameof(pollId));
62+
63+
await _lowLevelClient.InternalPollsApi.DeletePollAsync(pollId);
64+
65+
// Remove from cache if present
66+
if (_cache.Polls.TryGet(pollId, out var poll))
67+
{
68+
_cache.Polls.Remove(poll);
69+
}
70+
}
71+
5972
internal StreamPollsApi(StreamChatLowLevelClient lowLevelClient, ICache cache)
6073
{
6174
_lowLevelClient = lowLevelClient ?? throw new ArgumentNullException(nameof(lowLevelClient));

0 commit comments

Comments
 (0)