File tree Expand file tree Collapse file tree
source-code/app/src/main/java/com/hackeros/app/data/parser/repository Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ class PreferencesRepository(private val context: Context) {
2020 val THEME_KEY = stringPreferencesKey(" hackeros_theme" )
2121 val LANG_KEY = stringPreferencesKey(" hackeros_lang" )
2222 val NOTIFICATIONS_KEY = booleanPreferencesKey(" hackeros_notifications" )
23+ val LAST_KNOWN_VERSION_KEY = stringPreferencesKey(" hackeros_last_known_version" )
2324 }
2425
2526 val themeFlow: Flow <ThemeId > = context.dataStore.data.map { prefs ->
@@ -36,6 +37,13 @@ class PreferencesRepository(private val context: Context) {
3637 prefs[NOTIFICATIONS_KEY ] ? : false
3738 }
3839
40+ // Version of the release that was last seen (either shown in-app or already notified
41+ // about), used by the background worker to detect genuinely *new* releases and avoid
42+ // notifying about a version the user has already seen.
43+ val lastKnownVersionFlow: Flow <String ?> = context.dataStore.data.map { prefs ->
44+ prefs[LAST_KNOWN_VERSION_KEY ]
45+ }
46+
3947 suspend fun saveTheme (themeId : ThemeId ) {
4048 context.dataStore.edit { it[THEME_KEY ] = themeId.name }
4149 }
@@ -47,4 +55,8 @@ class PreferencesRepository(private val context: Context) {
4755 suspend fun saveNotifications (enabled : Boolean ) {
4856 context.dataStore.edit { it[NOTIFICATIONS_KEY ] = enabled }
4957 }
58+
59+ suspend fun saveLastKnownVersion (version : String ) {
60+ context.dataStore.edit { it[LAST_KNOWN_VERSION_KEY ] = version }
61+ }
5062}
You can’t perform that action at this time.
0 commit comments