diff --git a/client/src/main/java/app/kula/onlaunch/client/data/local/OnLaunchDataStore.kt b/client/src/main/java/app/kula/onlaunch/client/data/local/OnLaunchDataStore.kt index 5eeac94..7822e9c 100644 --- a/client/src/main/java/app/kula/onlaunch/client/data/local/OnLaunchDataStore.kt +++ b/client/src/main/java/app/kula/onlaunch/client/data/local/OnLaunchDataStore.kt @@ -6,9 +6,7 @@ import androidx.datastore.preferences.core.Preferences import androidx.datastore.preferences.core.edit import androidx.datastore.preferences.core.stringSetPreferencesKey import androidx.datastore.preferences.preferencesDataStore -import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.first -import kotlinx.coroutines.withContext private val KEY_DISMISSED_MESSAGE_IDS = stringSetPreferencesKey("isDataSharingEnabled") @@ -16,17 +14,13 @@ internal class OnLaunchDataStore(context: Context) { private val dataStore: DataStore = context.onLaunchDataStore - suspend fun getDismissedMessageIds(): Set = withContext(Dispatchers.IO) { - dataStore.data.first().let { - it[KEY_DISMISSED_MESSAGE_IDS]?.map(String::toInt)?.toSet() ?: emptySet() - } + suspend fun getDismissedMessageIds(): Set = dataStore.data.first().let { + it[KEY_DISMISSED_MESSAGE_IDS]?.map(String::toInt)?.toSet() ?: emptySet() } - suspend fun addDismissedMessageId(messageId: Int) = withContext(Dispatchers.IO) { - dataStore.edit { - it[KEY_DISMISSED_MESSAGE_IDS] = - (it[KEY_DISMISSED_MESSAGE_IDS] ?: emptySet()) + messageId.toString() - } + suspend fun addDismissedMessageId(messageId: Int) = dataStore.edit { + it[KEY_DISMISSED_MESSAGE_IDS] = + (it[KEY_DISMISSED_MESSAGE_IDS] ?: emptySet()) + messageId.toString() } }