Improve push notifications (#4896)
Besides the refactoring these improvements: * Track last push distributor and reset settings and subscription on any incompatible change (ie. uninstall) * Only update (push) notification settings on server if needed * Allow to only fetch notifications for one account (the one for which a push message was received) This is (also) the revival of https://github.com/tuskyapp/Tusky/pull/3642 It's not really well tested so far. (Ie. with two or more accounts or two or more push providers.)
This commit is contained in:
parent
f95dbe82b0
commit
6450af6edb
14 changed files with 274 additions and 127 deletions
|
|
@ -68,13 +68,19 @@ class TuskyApplication : Application(), Configuration.Provider {
|
|||
|
||||
Security.insertProviderAt(Conscrypt.newProvider(), 1)
|
||||
|
||||
val workManager = WorkManager.getInstance(this)
|
||||
|
||||
// Migrate shared preference keys and defaults from version to version.
|
||||
val oldVersion = preferences.getInt(
|
||||
PrefKeys.SCHEMA_VERSION,
|
||||
NEW_INSTALL_SCHEMA_VERSION
|
||||
)
|
||||
if (oldVersion != SCHEMA_VERSION) {
|
||||
// TODO SCHEMA_VERSION is outdated / not updated in code
|
||||
if (oldVersion < 2025021701) {
|
||||
// A new periodic work request is enqueued by unique name (and not tag anymore): stop the old one
|
||||
workManager.cancelAllWorkByTag("pullNotifications")
|
||||
}
|
||||
|
||||
upgradeSharedPreferences(oldVersion, SCHEMA_VERSION)
|
||||
}
|
||||
|
||||
|
|
@ -93,7 +99,7 @@ class TuskyApplication : Application(), Configuration.Provider {
|
|||
val pruneCacheWorker = PeriodicWorkRequestBuilder<PruneCacheWorker>(12, TimeUnit.HOURS)
|
||||
.setConstraints(Constraints.Builder().setRequiresDeviceIdle(true).build())
|
||||
.build()
|
||||
WorkManager.getInstance(this).enqueueUniquePeriodicWork(
|
||||
workManager.enqueueUniquePeriodicWork(
|
||||
PruneCacheWorker.PERIODIC_WORK_TAG,
|
||||
ExistingPeriodicWorkPolicy.KEEP,
|
||||
pruneCacheWorker
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue