feat: Enable background push

This commit is contained in:
Christian Pauly 2020-11-15 13:47:35 +01:00
parent dbbab93350
commit 1791ae85a7
3 changed files with 6 additions and 6 deletions

View File

@ -97,6 +97,7 @@ build_android_apk:
only: only:
- main - main
- tags - tags
- krille/enable-background-push
build_android_appbundle: build_android_appbundle:

View File

@ -15,7 +15,6 @@ Future<Database> getDatabase(Client client) async {
} }
_generateDatabaseLock = true; _generateDatabaseLock = true;
try { try {
if (_db != null) return _db;
final store = Store(); final store = Store();
var password = await store.getItem(SettingKeys.databasePassword); var password = await store.getItem(SettingKeys.databasePassword);
var newPassword = false; var newPassword = false;
@ -23,7 +22,7 @@ Future<Database> getDatabase(Client client) async {
newPassword = true; newPassword = true;
password = randomString(255); password = randomString(255);
} }
_db = await constructDb( final db = await constructDb(
logStatements: false, logStatements: false,
filename: 'moor.sqlite', filename: 'moor.sqlite',
password: password, password: password,
@ -31,13 +30,12 @@ Future<Database> getDatabase(Client client) async {
if (newPassword) { if (newPassword) {
await store.setItem(SettingKeys.databasePassword, password); await store.setItem(SettingKeys.databasePassword, password);
} }
return _db; return db;
} finally { } finally {
_generateDatabaseLock = false; _generateDatabaseLock = false;
} }
} }
Database _db;
bool _generateDatabaseLock = false; bool _generateDatabaseLock = false;
class Store { class Store {

View File

@ -27,7 +27,7 @@ abstract class FirebaseController {
static const String CHANNEL_ID = 'fluffychat_push'; static const String CHANNEL_ID = 'fluffychat_push';
static const String CHANNEL_NAME = 'FluffyChat push channel'; static const String CHANNEL_NAME = 'FluffyChat push channel';
static const String CHANNEL_DESCRIPTION = 'Push notifications for FluffyChat'; static const String CHANNEL_DESCRIPTION = 'Push notifications for FluffyChat';
static const String APP_ID = 'chat.fluffy.fluffychat'; static const String APP_ID = 'chat.fluffy.fluffychat.experimental';
static const String GATEWAY_URL = 'https://janian.de:7023/'; static const String GATEWAY_URL = 'https://janian.de:7023/';
static const String PUSHER_FORMAT = 'event_id_only'; static const String PUSHER_FORMAT = 'event_id_only';
@ -283,7 +283,8 @@ abstract class FirebaseController {
payload: roomId); payload: roomId);
if (tempClient) { if (tempClient) {
await client.dispose(); await client.dispose(closeDatabase: true);
client.database = null;
client = null; client = null;
debugPrint('[Push] Temp client disposed'); debugPrint('[Push] Temp client disposed');
} }