mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 21:32:34 +00:00
UnifiedPush WIP
This commit is contained in:
committed by
Benoit Marty
parent
8f565edb0a
commit
287fca5438
+2
-5
@@ -20,12 +20,9 @@ package io.element.android.libraries.pushstore.api
|
||||
* Store data related to push about a user.
|
||||
*/
|
||||
interface UserPushStore {
|
||||
/**
|
||||
* [NOTIFICATION_METHOD_FIREBASE] or [NOTIFICATION_METHOD_UNIFIEDPUSH].
|
||||
*/
|
||||
suspend fun getNotificationMethod(): String?
|
||||
suspend fun getPushProviderName(): String?
|
||||
|
||||
suspend fun setNotificationMethod(value: String)
|
||||
suspend fun setPushProviderName(value: String)
|
||||
|
||||
suspend fun getCurrentRegisteredPushKey(): String?
|
||||
|
||||
|
||||
+5
-5
@@ -33,16 +33,16 @@ class UserPushStoreDataStore(
|
||||
userId: String,
|
||||
) : UserPushStore {
|
||||
private val Context.dataStore: DataStore<Preferences> by preferencesDataStore(name = "push_store_$userId")
|
||||
private val notificationMethod = stringPreferencesKey("notificationMethod")
|
||||
private val pushProviderName = stringPreferencesKey("pushProviderName")
|
||||
private val currentPushKey = stringPreferencesKey("currentPushKey")
|
||||
|
||||
override suspend fun getNotificationMethod(): String? {
|
||||
return context.dataStore.data.first()[notificationMethod]
|
||||
override suspend fun getPushProviderName(): String? {
|
||||
return context.dataStore.data.first()[pushProviderName]
|
||||
}
|
||||
|
||||
override suspend fun setNotificationMethod(value: String) {
|
||||
override suspend fun setPushProviderName(value: String) {
|
||||
context.dataStore.edit {
|
||||
it[notificationMethod] = value
|
||||
it[pushProviderName] = value
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user