Fixes Missing Notifications
This commit is contained in:
@@ -232,7 +232,7 @@ open class Note(val idHex: String) {
|
|||||||
fun isZappedBy(user: User, account: Account): Boolean {
|
fun isZappedBy(user: User, account: Account): Boolean {
|
||||||
// Zaps who the requester was the user
|
// Zaps who the requester was the user
|
||||||
return zaps.any {
|
return zaps.any {
|
||||||
it.key.author === user || account.decryptZapContentAuthor(it.key)?.pubKey == user.pubkeyHex
|
it.key.author?.pubkeyHex == user.pubkeyHex || account.decryptZapContentAuthor(it.key)?.pubKey == user.pubkeyHex
|
||||||
} || zapPayments.any {
|
} || zapPayments.any {
|
||||||
val zapResponseEvent = it.value?.event as? LnZapPaymentResponseEvent
|
val zapResponseEvent = it.value?.event as? LnZapPaymentResponseEvent
|
||||||
val response = if (zapResponseEvent != null) {
|
val response = if (zapResponseEvent != null) {
|
||||||
@@ -245,11 +245,11 @@ open class Note(val idHex: String) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun isReactedBy(user: User): Boolean {
|
fun isReactedBy(user: User): Boolean {
|
||||||
return reactions.any { it.author === user }
|
return reactions.any { it.author?.pubkeyHex == user.pubkeyHex }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isBoostedBy(user: User): Boolean {
|
fun isBoostedBy(user: User): Boolean {
|
||||||
return boosts.any { it.author === user }
|
return boosts.any { it.author?.pubkeyHex == user.pubkeyHex }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun reportsBy(user: User): Set<Note> {
|
fun reportsBy(user: User): Set<Note> {
|
||||||
|
|||||||
@@ -299,7 +299,7 @@ class User(val pubkeyHex: String) {
|
|||||||
fun hasSentMessagesTo(user: User?): Boolean {
|
fun hasSentMessagesTo(user: User?): Boolean {
|
||||||
val messagesToUser = privateChatrooms[user] ?: return false
|
val messagesToUser = privateChatrooms[user] ?: return false
|
||||||
|
|
||||||
return messagesToUser.roomMessages.any { this === it.author }
|
return messagesToUser.roomMessages.any { this.pubkeyHex == it.author?.pubkeyHex }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun hasReport(loggedIn: User, type: ReportEvent.ReportType): Boolean {
|
fun hasReport(loggedIn: User, type: ReportEvent.ReportType): Boolean {
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ package com.vitorpamplona.amethyst.ui.dal
|
|||||||
|
|
||||||
import com.vitorpamplona.amethyst.model.Account
|
import com.vitorpamplona.amethyst.model.Account
|
||||||
import com.vitorpamplona.amethyst.model.GLOBAL_FOLLOWS
|
import com.vitorpamplona.amethyst.model.GLOBAL_FOLLOWS
|
||||||
|
import com.vitorpamplona.amethyst.model.HexKey
|
||||||
import com.vitorpamplona.amethyst.model.LocalCache
|
import com.vitorpamplona.amethyst.model.LocalCache
|
||||||
import com.vitorpamplona.amethyst.model.Note
|
import com.vitorpamplona.amethyst.model.Note
|
||||||
import com.vitorpamplona.amethyst.model.User
|
|
||||||
import com.vitorpamplona.amethyst.service.model.*
|
import com.vitorpamplona.amethyst.service.model.*
|
||||||
|
|
||||||
object NotificationFeedFilter : AdditiveFeedFilter<Note>() {
|
object NotificationFeedFilter : AdditiveFeedFilter<Note>() {
|
||||||
@@ -36,7 +36,7 @@ object NotificationFeedFilter : AdditiveFeedFilter<Note>() {
|
|||||||
(isGlobal || it.author?.pubkeyHex in followingKeySet) &&
|
(isGlobal || it.author?.pubkeyHex in followingKeySet) &&
|
||||||
it.event?.isTaggedUser(loggedInUserHex) ?: false &&
|
it.event?.isTaggedUser(loggedInUserHex) ?: false &&
|
||||||
(it.author == null || !account.isHidden(it.author!!.pubkeyHex)) &&
|
(it.author == null || !account.isHidden(it.author!!.pubkeyHex)) &&
|
||||||
tagsAnEventByUser(it, loggedInUser)
|
tagsAnEventByUser(it, loggedInUserHex)
|
||||||
}.toSet()
|
}.toSet()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,27 +44,27 @@ object NotificationFeedFilter : AdditiveFeedFilter<Note>() {
|
|||||||
return collection.sortedWith(compareBy({ it.createdAt() }, { it.idHex })).reversed()
|
return collection.sortedWith(compareBy({ it.createdAt() }, { it.idHex })).reversed()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun tagsAnEventByUser(note: Note, author: User): Boolean {
|
fun tagsAnEventByUser(note: Note, authorHex: HexKey): Boolean {
|
||||||
val event = note.event
|
val event = note.event
|
||||||
|
|
||||||
if (event is BaseTextNoteEvent) {
|
if (event is BaseTextNoteEvent) {
|
||||||
val isAuthoredPostCited = event.findCitations().any {
|
val isAuthoredPostCited = event.findCitations().any {
|
||||||
LocalCache.notes[it]?.author === author || LocalCache.addressables[it]?.author === author
|
LocalCache.notes[it]?.author?.pubkeyHex == authorHex || LocalCache.addressables[it]?.author?.pubkeyHex == authorHex
|
||||||
}
|
}
|
||||||
|
|
||||||
return isAuthoredPostCited ||
|
return isAuthoredPostCited ||
|
||||||
(
|
(
|
||||||
event.citedUsers().contains(author.pubkeyHex) ||
|
event.citedUsers().contains(authorHex) ||
|
||||||
note.replyTo?.any { it.author === author } == true
|
note.replyTo?.any { it.author?.pubkeyHex == authorHex } == true
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event is ReactionEvent) {
|
if (event is ReactionEvent) {
|
||||||
return note.replyTo?.lastOrNull()?.author === author
|
return note.replyTo?.lastOrNull()?.author?.pubkeyHex == authorHex
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event is RepostEvent) {
|
if (event is RepostEvent) {
|
||||||
return note.replyTo?.lastOrNull()?.author === author
|
return note.replyTo?.lastOrNull()?.author?.pubkeyHex == authorHex
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ fun ChatroomMessageCompose(
|
|||||||
LaunchedEffect(key1 = noteReportsState, key2 = accountState) {
|
LaunchedEffect(key1 = noteReportsState, key2 = accountState) {
|
||||||
withContext(Dispatchers.IO) {
|
withContext(Dispatchers.IO) {
|
||||||
account.userProfile().let { loggedIn ->
|
account.userProfile().let { loggedIn ->
|
||||||
val newCanPreview = note.author === loggedIn ||
|
val newCanPreview = note.author?.pubkeyHex == loggedIn.pubkeyHex ||
|
||||||
(note.author?.let { loggedIn.isFollowingCached(it) } ?: true) ||
|
(note.author?.let { loggedIn.isFollowingCached(it) } ?: true) ||
|
||||||
!(noteForReports.hasAnyReports())
|
!(noteForReports.hasAnyReports())
|
||||||
|
|
||||||
|
|||||||
@@ -452,7 +452,7 @@ fun FastNoteAuthorPicture(
|
|||||||
|
|
||||||
val showFollowingMark by remember(accountFollowsState) {
|
val showFollowingMark by remember(accountFollowsState) {
|
||||||
derivedStateOf {
|
derivedStateOf {
|
||||||
accountFollowsState?.user?.isFollowingCached(author) == true || (author === accountFollowsState?.user)
|
accountFollowsState?.user?.isFollowingCached(author) == true || (author.pubkeyHex == accountFollowsState?.user?.pubkeyHex)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ fun NoteCompose(
|
|||||||
LaunchedEffect(key1 = noteReportsState, key2 = accountState) {
|
LaunchedEffect(key1 = noteReportsState, key2 = accountState) {
|
||||||
withContext(Dispatchers.IO) {
|
withContext(Dispatchers.IO) {
|
||||||
account.userProfile().let { loggedIn ->
|
account.userProfile().let { loggedIn ->
|
||||||
val newCanPreview = note.author === loggedIn ||
|
val newCanPreview = note.author?.pubkeyHex == loggedIn.pubkeyHex ||
|
||||||
(note.author?.let { loggedIn.isFollowingCached(it) } ?: true) ||
|
(note.author?.let { loggedIn.isFollowingCached(it) } ?: true) ||
|
||||||
!(noteForReports.hasAnyReports())
|
!(noteForReports.hasAnyReports())
|
||||||
|
|
||||||
@@ -2030,7 +2030,7 @@ fun UserPicture(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val showFollowingMark = remember(accountState) {
|
val showFollowingMark = remember(accountState) {
|
||||||
accountState?.user?.isFollowingCached(baseUser) == true || baseUser === accountState?.user
|
accountState?.user?.isFollowingCached(baseUser) == true || baseUser.pubkeyHex == accountState?.user?.pubkeyHex
|
||||||
}
|
}
|
||||||
|
|
||||||
// BaseUser is the same reference as accountState.user
|
// BaseUser is the same reference as accountState.user
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ class AccountViewModel(private val account: Account) : ViewModel() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun isLoggedUser(user: User?): Boolean {
|
fun isLoggedUser(user: User?): Boolean {
|
||||||
return account.userProfile() === user
|
return account.userProfile().pubkeyHex == user?.pubkeyHex
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isFollowing(user: User?): Boolean {
|
fun isFollowing(user: User?): Boolean {
|
||||||
|
|||||||
Reference in New Issue
Block a user