Skip to content

Commit

Permalink
Clear state of affected feeds when the default clean-up mode is changed
Browse files Browse the repository at this point in the history
  • Loading branch information
tughi committed Mar 19, 2023
1 parent f7554c9 commit 2138a80
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
5 changes: 5 additions & 0 deletions app/src/main/java/com/tughi/aggregator/data/Feeds.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ object Feeds : Repository<Feeds.Column, Feeds.TableColumn, Feeds.UpdateCriteria,
override val selectionArgs = arrayOf<Any>(id)
}

class UpdateCleanupModeCriteria(cleanupMode: CleanupMode) : UpdateCriteria {
override val selection = "cleanup_mode = ?"
override val selectionArgs = arrayOf<Any>(cleanupMode.serialize())
}

interface DeleteCriteria : Repository.DeleteCriteria

object DeleteAllCriteria : DeleteCriteria {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import com.tughi.aggregator.App
import com.tughi.aggregator.contentScope
import com.tughi.aggregator.data.AdaptiveUpdateMode
import com.tughi.aggregator.data.CleanupMode
import com.tughi.aggregator.data.Database
import com.tughi.aggregator.data.DefaultCleanupMode
import com.tughi.aggregator.data.Feeds
import com.tughi.aggregator.data.UpdateMode
import com.tughi.aggregator.services.AutoUpdateScheduler
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -31,6 +34,17 @@ object UpdateSettings {
App.preferences.edit()
.putString(PREFERENCE_DEFAULT_CLEANUP_MODE, value.serialize())
.apply()

contentScope.launch {
// clear state to refresh affected feeds on next update
Database.transaction {
Feeds.update(
Feeds.UpdateCleanupModeCriteria(DefaultCleanupMode),
Feeds.HTTP_ETAG to null,
Feeds.HTTP_LAST_MODIFIED to null,
)
}
}
}

var defaultUpdateMode: UpdateMode
Expand Down
12 changes: 1 addition & 11 deletions metadata/en-US/changelogs/299033.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
- Enhanced OPML support
* allows selection of already aggregated feeds for import
* implemented export feature

- Added option to backup Aggregator's data
* data stored as gzipped ION file
* backup file contains all feeds, aggregated entries, configured tags and update settings

- Added option to restore Aggregator's data from a backup file
* any feeds or tags created before this action are permanently lost

- Removed automatic OPML backup
* users can use the export feature instead

* TODO: The app clears state of affected feeds when the default clean-up mode is changed
- Clear state of affected feeds when the default clean-up mode is changed

* TODO: Fix app-launch updates by using an OnBackPressedCallback to detect when the user leaves the MainActivity

0 comments on commit 2138a80

Please sign in to comment.