Making tags case insensitive

This commit is contained in:
Vitor Pamplona
2023-03-17 10:22:58 -04:00
parent 97ec28d2c8
commit 81e31319c7
3 changed files with 8 additions and 2 deletions

View File

@@ -330,7 +330,7 @@ class Account(
if (contactList != null && (followingUsers.isNotEmpty() || followingTags.isNotEmpty())) {
val event = ContactListEvent.create(
followingUsers,
followingTags.filter { it != tag },
followingTags.filter { !it.equals(tag, ignoreCase = true) },
contactList.relays(),
loggedIn.privKey!!
)

View File

@@ -257,6 +257,12 @@ class User(val pubkeyHex: String) {
} ?: false
}
fun isFollowingHashtagCached(tag: String): Boolean {
return latestContactList?.verifiedFollowTagSet?.let {
return tag.lowercase() in it
} ?: false
}
fun isFollowingCached(user: User): Boolean {
return latestContactList?.verifiedFollowKeySet?.let {
return user.pubkeyHex in it

View File

@@ -107,7 +107,7 @@ fun HashtagHeader(tag: String, account: Account) {
modifier = Modifier.weight(1f)
)
if (userFollows.isFollowingHashtag(tag)) {
if (userFollows.isFollowingHashtagCached(tag)) {
UnfollowButton { coroutineScope.launch(Dispatchers.IO) { account.unfollow(tag) } }
} else {
FollowButton { coroutineScope.launch(Dispatchers.IO) { account.follow(tag) } }