Make baseUrl and topic unique

This commit is contained in:
Philipp Heckel 2021-10-30 08:57:20 -04:00
parent fb755d486a
commit 8b2dc16861
2 changed files with 2 additions and 2 deletions

View file

@ -4,7 +4,7 @@ import android.content.Context
import androidx.room.*
import kotlinx.coroutines.flow.Flow
@Entity
@Entity(indices = [Index(value = ["baseUrl", "topic"], unique = true)])
data class Subscription(
@PrimaryKey val id: Long, // Internal ID, only used in Repository and activities
@ColumnInfo(name = "baseUrl") val baseUrl: String,

View file

@ -102,7 +102,7 @@ class MainActivity : AppCompatActivity(), AddFragment.AddSubscriptionListener {
}
override fun onSubscribe(topic: String, baseUrl: String) {
val subscription = Subscription(Random.nextLong(), topic, baseUrl, messages = 0)
val subscription = Subscription(id = Random.nextLong(), baseUrl = baseUrl, topic = topic, messages = 0)
subscriptionsViewModel.add(subscription)
FirebaseMessaging.getInstance().subscribeToTopic(topic) // FIXME ignores baseUrl
}