Run automatic backups after database imports - 1.131

This commit is contained in:
Brandon Presley 2023-03-09 18:46:14 +13:00
parent 13b340f5be
commit 79a48b1e47
4 changed files with 9 additions and 4 deletions

View File

@ -245,9 +245,12 @@ export default function SettingsPage() {
await AppDataSource.initialize() await AppDataSource.initialize()
await setRepo.createQueryBuilder().update().set({image: null}).execute() await setRepo.createQueryBuilder().update().set({image: null}).execute()
await update('sound', null) await update('sound', null)
const {alarm, backup} = await settingsRepo.findOne({where: {}})
console.log({backup})
if (backup) NativeModules.BackupModule.start()
else NativeModules.BackupModule.stop()
NativeModules.SettingsModule.ignoringBattery( NativeModules.SettingsModule.ignoringBattery(
async (isIgnoring: boolean) => { async (isIgnoring: boolean) => {
const {alarm} = await settingsRepo.findOne({where: {}})
if (alarm && !isIgnoring) NativeModules.SettingsModule.ignoreBattery() if (alarm && !isIgnoring) NativeModules.SettingsModule.ignoreBattery()
reset({index: 0, routes: [{name: 'Settings'}]}) reset({index: 0, routes: [{name: 'Settings'}]})
}, },

View File

@ -41,8 +41,8 @@ android {
missingDimensionStrategy "RNNotifications.reactNativeVersion", "reactNative60" missingDimensionStrategy "RNNotifications.reactNativeVersion", "reactNative60"
minSdkVersion rootProject.ext.minSdkVersion minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 36156 versionCode 36157
versionName "1.130" versionName "1.131"
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString() buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
if (isNewArchitectureEnabled()) { if (isNewArchitectureEnabled()) {

View File

@ -8,6 +8,7 @@ import android.content.Intent
import android.content.IntentFilter import android.content.IntentFilter
import android.os.Build import android.os.Build
import android.os.Environment import android.os.Environment
import android.util.Log
import androidx.annotation.RequiresApi import androidx.annotation.RequiresApi
import com.facebook.react.bridge.ReactApplicationContext import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.ReactContextBaseJavaModule import com.facebook.react.bridge.ReactContextBaseJavaModule
@ -24,6 +25,7 @@ class BackupModule constructor(context: ReactApplicationContext?) :
private val copyReceiver = object : BroadcastReceiver() { private val copyReceiver = object : BroadcastReceiver() {
@RequiresApi(Build.VERSION_CODES.O) @RequiresApi(Build.VERSION_CODES.O)
override fun onReceive(context: Context?, intent: Intent?) { override fun onReceive(context: Context?, intent: Intent?) {
Log.d("BackupModule", "Backing up database...")
val sourceFile = File(context?.getDatabasePath("massive.db")!!.path) val sourceFile = File(context?.getDatabasePath("massive.db")!!.path)
val targetDir = val targetDir =

View File

@ -1,6 +1,6 @@
{ {
"name": "massive", "name": "massive",
"version": "1.130", "version": "1.131",
"private": true, "private": true,
"license": "GPL-3.0-only", "license": "GPL-3.0-only",
"scripts": { "scripts": {