mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-10-10 04:55:03 +02:00
The live follows is held at the User not at the Account.
This commit is contained in:
@@ -41,7 +41,7 @@ class LocalPreferences(context: Context) {
|
|||||||
account.dontTranslateFrom.let { putStringSet("dontTranslateFrom", it) }
|
account.dontTranslateFrom.let { putStringSet("dontTranslateFrom", it) }
|
||||||
account.translateTo.let { putString("translateTo", it) }
|
account.translateTo.let { putString("translateTo", it) }
|
||||||
account.zapAmountChoices.let { putString("zapAmounts", gson.toJson(it)) }
|
account.zapAmountChoices.let { putString("zapAmounts", gson.toJson(it)) }
|
||||||
account.latestContactList.let { putString("latestContactList", Event.gson.toJson(it)) }
|
account.backupContactList.let { putString("latestContactList", Event.gson.toJson(it)) }
|
||||||
}.apply()
|
}.apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -58,7 +58,7 @@ class Account(
|
|||||||
var dontTranslateFrom: Set<String> = getLanguagesSpokenByUser(),
|
var dontTranslateFrom: Set<String> = getLanguagesSpokenByUser(),
|
||||||
var translateTo: String = Locale.getDefault().language,
|
var translateTo: String = Locale.getDefault().language,
|
||||||
var zapAmountChoices: List<Long> = listOf(500L, 1000L, 5000L),
|
var zapAmountChoices: List<Long> = listOf(500L, 1000L, 5000L),
|
||||||
var latestContactList: ContactListEvent? = null
|
var backupContactList: ContactListEvent? = null
|
||||||
) {
|
) {
|
||||||
var transientHiddenUsers: Set<String> = setOf()
|
var transientHiddenUsers: Set<String> = setOf()
|
||||||
|
|
||||||
@@ -86,7 +86,7 @@ class Account(
|
|||||||
fun sendNewRelayList(relays: Map<String, ContactListEvent.ReadWrite>) {
|
fun sendNewRelayList(relays: Map<String, ContactListEvent.ReadWrite>) {
|
||||||
if (!isWriteable()) return
|
if (!isWriteable()) return
|
||||||
|
|
||||||
val contactList = latestContactList
|
val contactList = userProfile().latestContactList
|
||||||
|
|
||||||
if (contactList != null && contactList.follows.size > 0) {
|
if (contactList != null && contactList.follows.size > 0) {
|
||||||
val event = ContactListEvent.create(
|
val event = ContactListEvent.create(
|
||||||
@@ -219,7 +219,7 @@ class Account(
|
|||||||
fun follow(user: User) {
|
fun follow(user: User) {
|
||||||
if (!isWriteable()) return
|
if (!isWriteable()) return
|
||||||
|
|
||||||
val contactList = latestContactList
|
val contactList = userProfile().latestContactList
|
||||||
|
|
||||||
val event = if (contactList != null && contactList.follows.size > 0) {
|
val event = if (contactList != null && contactList.follows.size > 0) {
|
||||||
ContactListEvent.create(
|
ContactListEvent.create(
|
||||||
@@ -242,7 +242,7 @@ class Account(
|
|||||||
fun unfollow(user: User) {
|
fun unfollow(user: User) {
|
||||||
if (!isWriteable()) return
|
if (!isWriteable()) return
|
||||||
|
|
||||||
val contactList = latestContactList
|
val contactList = userProfile().latestContactList
|
||||||
|
|
||||||
if (contactList != null && contactList.follows.size > 0) {
|
if (contactList != null && contactList.follows.size > 0) {
|
||||||
val event = ContactListEvent.create(
|
val event = ContactListEvent.create(
|
||||||
@@ -421,8 +421,8 @@ class Account(
|
|||||||
if (newContactList?.follows.isNullOrEmpty()) return
|
if (newContactList?.follows.isNullOrEmpty()) return
|
||||||
|
|
||||||
// Events might be different objects, we have to compare their ids.
|
// Events might be different objects, we have to compare their ids.
|
||||||
if (latestContactList?.id?.toHex() != newContactList?.id?.toHex()) {
|
if (backupContactList?.id?.toHex() != newContactList?.id?.toHex()) {
|
||||||
latestContactList = newContactList
|
backupContactList = newContactList
|
||||||
saveable.invalidateData()
|
saveable.invalidateData()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -492,7 +492,7 @@ class Account(
|
|||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
latestContactList?.let {
|
backupContactList?.let {
|
||||||
println("Loading saved contacts ${it.toJson()}")
|
println("Loading saved contacts ${it.toJson()}")
|
||||||
if (userProfile().latestContactList == null) {
|
if (userProfile().latestContactList == null) {
|
||||||
LocalCache.consume(it)
|
LocalCache.consume(it)
|
||||||
@@ -508,9 +508,7 @@ class Account(
|
|||||||
|
|
||||||
// saves contact list for the next time.
|
// saves contact list for the next time.
|
||||||
userProfile().live().follows.observeForever {
|
userProfile().live().follows.observeForever {
|
||||||
GlobalScope.launch(Dispatchers.IO) {
|
updateContactListTo(userProfile().latestContactList)
|
||||||
updateContactListTo(userProfile().latestContactList)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// imports transient blocks due to spam.
|
// imports transient blocks due to spam.
|
||||||
|
Reference in New Issue
Block a user