mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-23 02:10:44 +01:00
Add support for separate story view receipt control.
This reverts commit 1046265d23.
This commit is contained in:
committed by
Cody Henthorne
parent
2f2711c9a3
commit
ca36eaacce
@@ -109,9 +109,10 @@ public class ApplicationMigrations {
|
||||
static final int KBS_MIGRATION_2 = 65;
|
||||
static final int PNI_2 = 66;
|
||||
static final int SYSTEM_NAME_SYNC = 67;
|
||||
static final int STORY_VIEWED_STATE = 68;
|
||||
}
|
||||
|
||||
public static final int CURRENT_VERSION = 67;
|
||||
public static final int CURRENT_VERSION = 68;
|
||||
|
||||
/**
|
||||
* This *must* be called after the {@link JobManager} has been instantiated, but *before* the call
|
||||
@@ -481,6 +482,10 @@ public class ApplicationMigrations {
|
||||
jobs.put(Version.SYSTEM_NAME_SYNC, new StorageServiceSystemNameMigrationJob());
|
||||
}
|
||||
|
||||
if (lastSeenVersion < Version.STORY_VIEWED_STATE) {
|
||||
jobs.put(Version.STORY_VIEWED_STATE, new StoryViewedReceiptsStateMigrationJob());
|
||||
}
|
||||
|
||||
return jobs;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package org.thoughtcrime.securesms.migrations
|
||||
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase.Companion.recipients
|
||||
import org.thoughtcrime.securesms.jobmanager.Data
|
||||
import org.thoughtcrime.securesms.jobmanager.Job
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.storage.StorageSyncHelper
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||
|
||||
/**
|
||||
* Added as a way to initialize the story viewed receipts setting.
|
||||
*/
|
||||
internal class StoryViewedReceiptsStateMigrationJob(
|
||||
parameters: Parameters = Parameters.Builder().build()
|
||||
) : MigrationJob(parameters) {
|
||||
companion object {
|
||||
const val KEY = "StoryViewedReceiptsStateMigrationJob"
|
||||
}
|
||||
|
||||
override fun getFactoryKey(): String = KEY
|
||||
|
||||
override fun isUiBlocking(): Boolean = false
|
||||
|
||||
override fun performMigration() {
|
||||
if (!SignalStore.storyValues().isViewedReceiptsStateSet()) {
|
||||
SignalStore.storyValues().viewedReceiptsEnabled = TextSecurePreferences.isReadReceiptsEnabled(context)
|
||||
if (SignalStore.account().isRegistered) {
|
||||
recipients.markNeedsSync(Recipient.self().id)
|
||||
StorageSyncHelper.scheduleSyncForDataChange()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun shouldRetry(e: Exception): Boolean = false
|
||||
|
||||
class Factory : Job.Factory<StoryViewedReceiptsStateMigrationJob> {
|
||||
override fun create(parameters: Parameters, data: Data): StoryViewedReceiptsStateMigrationJob {
|
||||
return StoryViewedReceiptsStateMigrationJob(parameters)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user