Merge branch 'dev' of https://github.com/oxen-io/session-android into client-side-nickname

This commit is contained in:
Ryan ZHAO
2021-05-07 16:31:54 +10:00
8 changed files with 52 additions and 28 deletions

View File

@@ -158,8 +158,8 @@ dependencies {
testImplementation 'org.robolectric:shadows-multidex:4.2'
}
def canonicalVersionCode = 157
def canonicalVersionName = "1.10.0"
def canonicalVersionCode = 158
def canonicalVersionName = "1.10.1"
def postFixSize = 10
def abiPostFix = ['armeabi-v7a' : 1,

View File

@@ -103,7 +103,6 @@ import dagger.ObjectGraph;
import kotlin.Unit;
import kotlinx.coroutines.Job;
import network.loki.messenger.BuildConfig;
import nl.komponents.kovenant.Kovenant;
import static nl.komponents.kovenant.android.KovenantAndroid.startKovenant;
import static nl.komponents.kovenant.android.KovenantAndroid.stopKovenant;

View File

@@ -180,15 +180,15 @@ class Storage(context: Context, helper: SQLCipherOpenHelper) : Database(context,
DatabaseFactory.getSessionJobDatabase(context).persistJob(job)
}
override fun markJobAsSucceeded(job: Job) {
DatabaseFactory.getSessionJobDatabase(context).markJobAsSucceeded(job)
override fun markJobAsSucceeded(jobId: String) {
DatabaseFactory.getSessionJobDatabase(context).markJobAsSucceeded(jobId)
}
override fun markJobAsFailed(job: Job) {
DatabaseFactory.getSessionJobDatabase(context).markJobAsFailed(job)
override fun markJobAsFailed(jobId: String) {
DatabaseFactory.getSessionJobDatabase(context).markJobAsFailed(jobId)
}
override fun getAllPendingJobs(type: String): List<Job> {
override fun getAllPendingJobs(type: String): Map<String, Job?> {
return DatabaseFactory.getSessionJobDatabase(context).getAllPendingJobs(type)
}

View File

@@ -4,6 +4,7 @@ import android.content.ContentValues
import android.content.Context
import net.sqlcipher.Cursor
import org.session.libsession.messaging.jobs.*
import org.session.libsignal.utilities.logging.Log
import org.thoughtcrime.securesms.database.Database
import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper
import org.thoughtcrime.securesms.jobmanager.impl.JsonDataSerializer
@@ -30,19 +31,25 @@ class SessionJobDatabase(context: Context, helper: SQLCipherOpenHelper) : Databa
database.insertOrUpdate(sessionJobTable, contentValues, "$jobID = ?", arrayOf(jobID))
}
fun markJobAsSucceeded(job: Job) {
databaseHelper.writableDatabase.delete(sessionJobTable, "$jobID = ?", arrayOf(job.id))
fun markJobAsSucceeded(jobId: String) {
databaseHelper.writableDatabase.delete(sessionJobTable, "$jobID = ?", arrayOf(jobId))
}
fun markJobAsFailed(job: Job) {
databaseHelper.writableDatabase.delete(sessionJobTable, "$jobID = ?", arrayOf(job.id))
fun markJobAsFailed(jobId: String) {
databaseHelper.writableDatabase.delete(sessionJobTable, "$jobID = ?", arrayOf(jobId))
}
fun getAllPendingJobs(type: String): List<Job> {
fun getAllPendingJobs(type: String): Map<String, Job?> {
val database = databaseHelper.readableDatabase
return database.getAll(sessionJobTable, "$jobType = ?", arrayOf(type)) { cursor ->
jobFromCursor(cursor)
}
val jobId = cursor.getString(jobID)
try {
jobId to jobFromCursor(cursor)
} catch (e: Exception) {
Log.e("Loki", "Error serializing Job of type $type",e)
jobId to null
}
}.toMap()
}
fun getAttachmentUploadJob(attachmentID: Long): AttachmentUploadJob? {