Removing warnings
This commit is contained in:
@@ -90,8 +90,7 @@ class AddressableNote(
|
|||||||
override fun address() = address
|
override fun address() = address
|
||||||
|
|
||||||
override fun createdAt(): Long? {
|
override fun createdAt(): Long? {
|
||||||
val currentEvent = event
|
val currentEvent = event ?: return null
|
||||||
if (currentEvent == null) return null
|
|
||||||
if (currentEvent is PublishedAtProvider) return currentEvent.publishedAt() ?: currentEvent.createdAt
|
if (currentEvent is PublishedAtProvider) return currentEvent.publishedAt() ?: currentEvent.createdAt
|
||||||
return currentEvent.createdAt
|
return currentEvent.createdAt
|
||||||
}
|
}
|
||||||
@@ -204,7 +203,7 @@ open class Note(
|
|||||||
|
|
||||||
is IsInPublicChatChannel -> {
|
is IsInPublicChatChannel -> {
|
||||||
inGatherers?.forEach {
|
inGatherers?.forEach {
|
||||||
if (it is com.vitorpamplona.amethyst.commons.model.Channel) {
|
if (it is Channel) {
|
||||||
it.relays().firstOrNull()?.let { return it }
|
it.relays().firstOrNull()?.let { return it }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -216,7 +215,7 @@ open class Note(
|
|||||||
|
|
||||||
is LiveActivitiesChatMessageEvent -> {
|
is LiveActivitiesChatMessageEvent -> {
|
||||||
inGatherers?.forEach {
|
inGatherers?.forEach {
|
||||||
if (it is com.vitorpamplona.amethyst.commons.model.Channel) {
|
if (it is Channel) {
|
||||||
it.relays().firstOrNull()?.let { return it }
|
it.relays().firstOrNull()?.let { return it }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -230,14 +229,14 @@ open class Note(
|
|||||||
val currentOutbox = author?.outboxRelays()?.toSet()
|
val currentOutbox = author?.outboxRelays()?.toSet()
|
||||||
|
|
||||||
return if (relays.isNotEmpty()) {
|
return if (relays.isNotEmpty()) {
|
||||||
if (currentOutbox != null && currentOutbox.isNotEmpty()) {
|
if (!currentOutbox.isNullOrEmpty()) {
|
||||||
val relayMatchesOutbox = relays.firstOrNull { it in currentOutbox }
|
val relayMatchesOutbox = relays.firstOrNull { it in currentOutbox }
|
||||||
if (relayMatchesOutbox != null) {
|
if (relayMatchesOutbox != null) {
|
||||||
return relayMatchesOutbox
|
return relayMatchesOutbox
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return relays.firstOrNull()
|
relays.firstOrNull()
|
||||||
} else {
|
} else {
|
||||||
currentOutbox?.firstOrNull() ?: author?.mostUsedNonLocalRelay()
|
currentOutbox?.firstOrNull() ?: author?.mostUsedNonLocalRelay()
|
||||||
}
|
}
|
||||||
@@ -313,14 +312,14 @@ open class Note(
|
|||||||
zapPayments.keys +
|
zapPayments.keys +
|
||||||
zapPayments.values.filterNotNull()
|
zapPayments.values.filterNotNull()
|
||||||
|
|
||||||
replies = listOf<Note>()
|
replies = listOf()
|
||||||
reactions = mapOf<String, List<Note>>()
|
reactions = mapOf()
|
||||||
boosts = listOf<Note>()
|
boosts = listOf()
|
||||||
reports = mapOf<User, List<Note>>()
|
reports = mapOf()
|
||||||
zaps = mapOf<Note, Note?>()
|
zaps = mapOf()
|
||||||
zapPayments = mapOf<Note, Note?>()
|
zapPayments = mapOf()
|
||||||
zapsAmount = BigDecimal.ZERO
|
zapsAmount = BigDecimal.ZERO
|
||||||
relays = listOf<NormalizedRelayUrl>()
|
relays = listOf()
|
||||||
|
|
||||||
if (repliesChanged) flowSet?.replies?.invalidateData()
|
if (repliesChanged) flowSet?.replies?.invalidateData()
|
||||||
if (reactionsChanged) flowSet?.reactions?.invalidateData()
|
if (reactionsChanged) flowSet?.reactions?.invalidateData()
|
||||||
@@ -990,11 +989,11 @@ class NoteState(
|
|||||||
|
|
||||||
fun List<AddressableNote>.eventIdSet() = mapNotNullTo(mutableSetOf<HexKey>()) { it.event?.id }
|
fun List<AddressableNote>.eventIdSet() = mapNotNullTo(mutableSetOf<HexKey>()) { it.event?.id }
|
||||||
|
|
||||||
fun <T : Event> Array<NoteState>.events() = mapNotNull { it.note.event as? T }
|
inline fun <reified T : Event> Array<NoteState>.events() = mapNotNull { it.note.event as? T }
|
||||||
|
|
||||||
fun <T : Event> List<AddressableNote>.events() = mapNotNull { it.event as? T }
|
inline fun <reified T : Event> List<AddressableNote>.events() = mapNotNull { it.event as? T }
|
||||||
|
|
||||||
fun <T : Event> List<AddressableNote>.updateFlow(): Flow<List<T>> =
|
inline fun <reified T : Event> List<AddressableNote>.updateFlow(): Flow<List<T>> =
|
||||||
if (this.isEmpty()) {
|
if (this.isEmpty()) {
|
||||||
MutableStateFlow(emptyList())
|
MutableStateFlow(emptyList())
|
||||||
} else {
|
} else {
|
||||||
@@ -1005,7 +1004,7 @@ fun <T : Event> List<AddressableNote>.updateFlow(): Flow<List<T>> =
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public inline fun <T> Iterable<Note>.anyEvent(predicate: (T) -> Boolean): Boolean {
|
inline fun <reified T : Event> Iterable<Note>.anyEvent(predicate: (T) -> Boolean): Boolean {
|
||||||
if (this is Collection && isEmpty()) return false
|
if (this is Collection && isEmpty()) return false
|
||||||
for (note in this) {
|
for (note in this) {
|
||||||
val noteEvent = note.event as? T
|
val noteEvent = note.event as? T
|
||||||
@@ -1014,7 +1013,7 @@ public inline fun <T> Iterable<Note>.anyEvent(predicate: (T) -> Boolean): Boolea
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
public inline fun <T> Iterable<Note>.filterEvents(predicate: (T) -> Boolean): List<T> {
|
inline fun <reified T : Event> Iterable<Note>.filterEvents(predicate: (T) -> Boolean): List<T> {
|
||||||
if (this is Collection && isEmpty()) return emptyList()
|
if (this is Collection && isEmpty()) return emptyList()
|
||||||
|
|
||||||
val dest = ArrayList<T>()
|
val dest = ArrayList<T>()
|
||||||
@@ -1027,7 +1026,7 @@ public inline fun <T> Iterable<Note>.filterEvents(predicate: (T) -> Boolean): Li
|
|||||||
return dest
|
return dest
|
||||||
}
|
}
|
||||||
|
|
||||||
public fun <T> Iterable<Note>.filterAuthoredEvents(pubkey: HexKey): List<T> {
|
inline fun <reified T : Event> Iterable<Note>.filterAuthoredEvents(pubkey: HexKey): List<T> {
|
||||||
if (this is Collection && isEmpty()) return emptyList()
|
if (this is Collection && isEmpty()) return emptyList()
|
||||||
|
|
||||||
val dest = ArrayList<T>()
|
val dest = ArrayList<T>()
|
||||||
@@ -1042,7 +1041,7 @@ public fun <T> Iterable<Note>.filterAuthoredEvents(pubkey: HexKey): List<T> {
|
|||||||
return dest
|
return dest
|
||||||
}
|
}
|
||||||
|
|
||||||
public inline fun Iterable<Note>.anyNotNullEvent(predicate: (Event) -> Boolean): Boolean {
|
inline fun Iterable<Note>.anyNotNullEvent(predicate: (Event) -> Boolean): Boolean {
|
||||||
if (this is Collection && isEmpty()) return false
|
if (this is Collection && isEmpty()) return false
|
||||||
for (note in this) {
|
for (note in this) {
|
||||||
val noteEvent = note.event
|
val noteEvent = note.event
|
||||||
@@ -1051,7 +1050,7 @@ public inline fun Iterable<Note>.anyNotNullEvent(predicate: (Event) -> Boolean):
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <T : Event> List<Note>.latestByAuthor(): Map<User, T> {
|
inline fun <reified T : Event> List<Note>.latestByAuthor(): Map<User, T> {
|
||||||
val oneResponsePerUser = mutableMapOf<User, T>()
|
val oneResponsePerUser = mutableMapOf<User, T>()
|
||||||
|
|
||||||
forEach { note ->
|
forEach { note ->
|
||||||
|
|||||||
Reference in New Issue
Block a user