Commit 10d6196c authored by Leonardo Aramaki's avatar Leonardo Aramaki

Assert nulls before setting user's details to local cache

parent a4fb6a00
......@@ -408,7 +408,11 @@ object RocketChatCache {
}, BackpressureStrategy.LATEST)
}
fun setUserId(userId: String) = setString(KEY_USER_ID, userId)
fun setUserId(userId: String?) {
userId?.let {
setString(KEY_USER_ID, userId)
}
}
fun getUserId(): String? = getString(KEY_USER_ID, null)
......@@ -420,7 +424,11 @@ object RocketChatCache {
fun getUserName(): String? = getString(KEY_USER_NAME, null)
fun setUserUsername(username: String) = setString(KEY_USER_USERNAME, username)
fun setUserUsername(username: String?) {
username?.let {
setString(KEY_USER_USERNAME, username)
}
}
fun getUserUsername(): String? = getString(KEY_USER_USERNAME, null)
}
\ No newline at end of file
......@@ -57,11 +57,14 @@ public class CurrentUserObserver extends AbstractModelObserver<RealmUser> {
}
listeners = new ArrayList<>();
RocketChatCache.INSTANCE.setUserId(user.getId());
RocketChatCache.INSTANCE.setUserUsername(user.getUsername());
RocketChatCache.INSTANCE.setUserName(user.getName());
String userId = user.getId();
String username = user.getUsername();
String name = user.getName();
final String userId = user.getId();
RocketChatCache.INSTANCE.setUserId(userId);
RocketChatCache.INSTANCE.setUserUsername(username);
RocketChatCache.INSTANCE.setUserName(name);
// get and observe Room subscriptions.
methodCall.getRoomSubscriptions().onSuccess(task -> {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment