mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-23 10:20:25 +01:00
Add support for stories "seen" state.
This commit is contained in:
committed by
Cody Henthorne
parent
995a4ad6ec
commit
94bd3101c9
@@ -110,9 +110,10 @@ public class ApplicationMigrations {
|
||||
static final int PNI_2 = 66;
|
||||
static final int SYSTEM_NAME_SYNC = 67;
|
||||
static final int STORY_VIEWED_STATE = 68;
|
||||
static final int STORY_READ_STATE = 69;
|
||||
}
|
||||
|
||||
public static final int CURRENT_VERSION = 68;
|
||||
public static final int CURRENT_VERSION = 69;
|
||||
|
||||
/**
|
||||
* This *must* be called after the {@link JobManager} has been instantiated, but *before* the call
|
||||
@@ -486,6 +487,10 @@ public class ApplicationMigrations {
|
||||
jobs.put(Version.STORY_VIEWED_STATE, new StoryViewedReceiptsStateMigrationJob());
|
||||
}
|
||||
|
||||
if (lastSeenVersion < Version.STORY_READ_STATE) {
|
||||
jobs.put(Version.STORY_READ_STATE, new StoryReadStateMigrationJob());
|
||||
}
|
||||
|
||||
return jobs;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package org.thoughtcrime.securesms.migrations
|
||||
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase.Companion.mms
|
||||
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
|
||||
|
||||
/**
|
||||
* Added to initialize whether the user has seen the onboarding story
|
||||
*/
|
||||
internal class StoryReadStateMigrationJob(
|
||||
parameters: Parameters = Parameters.Builder().build()
|
||||
) : MigrationJob(parameters) {
|
||||
|
||||
companion object {
|
||||
const val KEY = "StoryReadStateMigrationJob"
|
||||
}
|
||||
|
||||
override fun getFactoryKey(): String = KEY
|
||||
|
||||
override fun isUiBlocking(): Boolean = false
|
||||
|
||||
override fun performMigration() {
|
||||
if (!SignalStore.storyValues().hasUserOnboardingStoryReadBeenSet()) {
|
||||
SignalStore.storyValues().userHasReadOnboardingStory = SignalStore.storyValues().userHasReadOnboardingStory
|
||||
mms.markOnboardingStoryRead()
|
||||
|
||||
if (SignalStore.account().isRegistered) {
|
||||
recipients.markNeedsSync(Recipient.self().id)
|
||||
StorageSyncHelper.scheduleSyncForDataChange()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun shouldRetry(e: Exception): Boolean = false
|
||||
|
||||
class Factory : Job.Factory<StoryReadStateMigrationJob> {
|
||||
override fun create(parameters: Parameters, data: Data): StoryReadStateMigrationJob {
|
||||
return StoryReadStateMigrationJob(parameters)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user