Skip to content

Commit

Permalink
Add importing new muteList events to primal api
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksandarIlic committed Oct 17, 2023
1 parent d1c20bd commit e60f2d3
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import kotlinx.coroutines.withContext
import kotlinx.serialization.json.JsonArray
import kotlinx.serialization.json.jsonPrimitive
import net.primal.android.db.PrimalDatabase
import net.primal.android.networking.primal.api.PrimalImportApi
import net.primal.android.nostr.ext.asProfileDataPO
import net.primal.android.nostr.ext.flatMapNotNullAsMediaResourcePO
import net.primal.android.settings.api.SettingsApi
Expand All @@ -15,6 +16,7 @@ import javax.inject.Inject
class MutedUserRepository @Inject constructor(
private val database: PrimalDatabase,
private val settingsApi: SettingsApi,
private val primalImportApi: PrimalImportApi,
) {

fun observeMutedUsers() = database.muted().observeMutedUsers()
Expand Down Expand Up @@ -62,7 +64,11 @@ class MutedUserRepository @Inject constructor(
) {
val remoteMuteList = fetchMuteListAndPersistProfiles(userId = userId)
val newMuteList = remoteMuteList.reducer()
settingsApi.setMuteList(userId = userId, muteList = newMuteList.map { it.userId }.toSet())
val muteListNostrEvent = settingsApi.setMuteList(
userId = userId,
muteList = newMuteList.map { it.userId }.toSet(),
)
primalImportApi.importEvents(listOf(muteListNostrEvent))
persistMuteList(muteList = newMuteList)
}

Expand Down

0 comments on commit e60f2d3

Please sign in to comment.