Fix minor crash.

This commit is contained in:
Mikunj 2019-12-04 13:33:05 +11:00
parent 5e5309d07e
commit fdba9023fc

View File

@ -278,10 +278,12 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
public @Nullable LokiPublicChatAPI getLokiPublicChatAPI() { public @Nullable LokiPublicChatAPI getLokiPublicChatAPI() {
if (lokiPublicChatAPI == null && IdentityKeyUtil.hasIdentityKey(this)) { if (lokiPublicChatAPI == null && IdentityKeyUtil.hasIdentityKey(this)) {
String userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(this); String userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(this);
byte[] userPrivateKey = IdentityKeyUtil.getIdentityKeyPair(this).getPrivateKey().serialize(); if (userHexEncodedPublicKey != null) {
LokiAPIDatabase apiDatabase = DatabaseFactory.getLokiAPIDatabase(this); byte[] userPrivateKey = IdentityKeyUtil.getIdentityKeyPair(this).getPrivateKey().serialize();
LokiUserDatabase userDatabase = DatabaseFactory.getLokiUserDatabase(this); LokiAPIDatabase apiDatabase = DatabaseFactory.getLokiAPIDatabase(this);
lokiPublicChatAPI = new LokiPublicChatAPI(userHexEncodedPublicKey, userPrivateKey, apiDatabase, userDatabase); LokiUserDatabase userDatabase = DatabaseFactory.getLokiUserDatabase(this);
lokiPublicChatAPI = new LokiPublicChatAPI(userHexEncodedPublicKey, userPrivateKey, apiDatabase, userDatabase);
}
} }
return lokiPublicChatAPI; return lokiPublicChatAPI;
} }