Skip to content

Commit 881ab34

Browse files
authored
Merge pull request #184 from GetStream/bugfix/fix-method-typo
Fix typo + add code example
2 parents 33da4f0 + c375c11 commit 881ab34

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

Assets/Plugins/StreamChat/Core/IStreamChatClient.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,15 +257,17 @@ Task<StreamDeleteChannelsResponse> DeleteMultipleChannelsAsync(IEnumerable<IStre
257257
/// Get current state of unread counts for the user. Unread counts mean how many messages and threads are unread in the channels and threads the user is participating in.
258258
///
259259
/// This method can be used in offline mode as well to poll the latest unread counts without establishing a connection.
260-
/// To use it this way, you need to call the <see cref="SeAuthorizationCredentials"/> method first to set the authorization credentials for the API call.
260+
/// To use it this way, you need to call the <see cref="SetAuthorizationCredentials"/> method first to set the authorization credentials for the API call.
261261
/// </summary>
262262
/// <returns><see cref="StreamCurrentUnreadCounts"/>Contains information about unread counts in channels and threads</returns>
263263
Task<StreamCurrentUnreadCounts> GetLatestUnreadCountsAsync();
264+
265+
//StreamTodo: create unit test that tests GetLatestUnreadCountsAsync in offline mode.
264266

265267
/// <summary>
266268
/// Set authorization credentials for the client to use when connecting to the API
267269
/// </summary>
268270
/// <param name="authCredentials">Credentials containing: api key, user ID, and a user Token</param>
269-
void SeAuthorizationCredentials(AuthCredentials authCredentials);
271+
void SetAuthorizationCredentials(AuthCredentials authCredentials);
270272
}
271273
}

Assets/Plugins/StreamChat/Core/StreamChatClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public static string CreateDeveloperAuthToken(string userId)
165165
/// <inheritdoc cref="StreamChatLowLevelClient.SanitizeUserId"/>
166166
public static string SanitizeUserId(string userId) => StreamChatLowLevelClient.SanitizeUserId(userId);
167167

168-
public void SeAuthorizationCredentials(AuthCredentials authCredentials)
168+
public void SetAuthorizationCredentials(AuthCredentials authCredentials)
169169
=> InternalLowLevelClient.SeAuthorizationCredentials(authCredentials);
170170

171171
public Task<IStreamLocalUserData> ConnectUserAsync(AuthCredentials userAuthCredentials,

Assets/Plugins/StreamChat/Samples/UnreadCountsCodeSamples.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Threading.Tasks;
22
using StreamChat.Core;
33
using StreamChat.Core.StatefulModels;
4+
using StreamChat.Libs.Auth;
45
using UnityEngine;
56

67
namespace StreamChat.Samples
@@ -98,6 +99,16 @@ public async Task GetCurrentUnreadCounts()
9899
Debug.Log(unreadThread.LastRead); // Datetime of the last read message
99100
}
100101
}
102+
103+
public async Task GetLatestUnreadCountsInOfflineMode()
104+
{
105+
// Set authorization credentials
106+
var authCredentials = new AuthCredentials("api_key", "user_id", "user_token");
107+
Client.SetAuthorizationCredentials(authCredentials);
108+
109+
// Retrieve unread counts without connecting to the chat service via Client.ConnectUserAsync
110+
var unreadCounts = await Client.GetLatestUnreadCountsAsync();
111+
}
101112

102113
private IStreamChatClient Client { get; } = StreamChatClient.CreateDefaultClient();
103114
}

0 commit comments

Comments
 (0)