Fix crashes

This commit is contained in:
Niels Andriesse 2020-01-17 09:33:31 +11:00
parent fbd197897f
commit 362256dc94

View File

@ -202,8 +202,6 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
mixpanel.trackMap(event, properties); mixpanel.trackMap(event, properties);
return Unit.INSTANCE; return Unit.INSTANCE;
}; };
// Loki - Set up public chat manager
lokiPublicChatManager = new LokiPublicChatManager(this);
// Loki - Set the cache // Loki - Set the cache
LokiDotNetAPI.setCache(new Cache(this.getCacheDir(), OK_HTTP_CACHE_SIZE)); LokiDotNetAPI.setCache(new Cache(this.getCacheDir(), OK_HTTP_CACHE_SIZE));
// Loki - Update device mappings // Loki - Update device mappings
@ -213,6 +211,8 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
checkNeedsRevocation(); checkNeedsRevocation();
} }
} }
// Loki - Set up public chat manager
lokiPublicChatManager = new LokiPublicChatManager(this);
updatePublicChatProfileAvatarIfNeeded(); updatePublicChatProfileAvatarIfNeeded();
} }
@ -282,10 +282,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;
} }