Adds notes to channels to facilitate their loading.
This commit is contained in:
@@ -852,7 +852,7 @@ object LocalCache : ILocalCache {
|
|||||||
|
|
||||||
val creator = event.host()?.let { checkGetOrCreateUser(it.pubKey) } ?: author
|
val creator = event.host()?.let { checkGetOrCreateUser(it.pubKey) } ?: author
|
||||||
|
|
||||||
channel.updateChannelInfo(creator, event)
|
channel.updateChannelInfo(creator, event, note)
|
||||||
|
|
||||||
refreshNewNoteObservers(note)
|
refreshNewNoteObservers(note)
|
||||||
|
|
||||||
@@ -1548,7 +1548,7 @@ object LocalCache : ILocalCache {
|
|||||||
|
|
||||||
if (oldChannel.creator == null || oldChannel.creator == author) {
|
if (oldChannel.creator == null || oldChannel.creator == author) {
|
||||||
if (isVerified || justVerify(event)) {
|
if (isVerified || justVerify(event)) {
|
||||||
oldChannel.updateChannelInfo(author, event)
|
oldChannel.updateChannelInfo(author, event, note)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1567,6 +1567,8 @@ object LocalCache : ILocalCache {
|
|||||||
val oldChannel = checkGetOrCreatePublicChatChannel(channelId) ?: return false
|
val oldChannel = checkGetOrCreatePublicChatChannel(channelId) ?: return false
|
||||||
|
|
||||||
val author = getOrCreateUser(event.pubKey)
|
val author = getOrCreateUser(event.pubKey)
|
||||||
|
val note = getOrCreateNote(event.id)
|
||||||
|
|
||||||
val isVerified =
|
val isVerified =
|
||||||
if (event.createdAt > oldChannel.updatedMetadataAt) {
|
if (event.createdAt > oldChannel.updatedMetadataAt) {
|
||||||
if (wasVerified || justVerify(event)) {
|
if (wasVerified || justVerify(event)) {
|
||||||
@@ -1579,7 +1581,6 @@ object LocalCache : ILocalCache {
|
|||||||
wasVerified
|
wasVerified
|
||||||
}
|
}
|
||||||
|
|
||||||
val note = getOrCreateNote(event.id)
|
|
||||||
if (note.event == null && (isVerified || justVerify(event))) {
|
if (note.event == null && (isVerified || justVerify(event))) {
|
||||||
oldChannel.addNote(note, relay)
|
oldChannel.addNote(note, relay)
|
||||||
note.loadEvent(event, author, emptyList())
|
note.loadEvent(event, author, emptyList())
|
||||||
|
|||||||
+6
-2
@@ -22,6 +22,7 @@ package com.vitorpamplona.amethyst.model.nip28PublicChats
|
|||||||
|
|
||||||
import androidx.compose.runtime.Stable
|
import androidx.compose.runtime.Stable
|
||||||
import com.vitorpamplona.amethyst.model.Channel
|
import com.vitorpamplona.amethyst.model.Channel
|
||||||
|
import com.vitorpamplona.amethyst.model.Note
|
||||||
import com.vitorpamplona.amethyst.model.User
|
import com.vitorpamplona.amethyst.model.User
|
||||||
import com.vitorpamplona.amethyst.ui.note.toShortDisplay
|
import com.vitorpamplona.amethyst.ui.note.toShortDisplay
|
||||||
import com.vitorpamplona.quartz.nip01Core.hints.EventHintBundle
|
import com.vitorpamplona.quartz.nip01Core.hints.EventHintBundle
|
||||||
@@ -39,6 +40,7 @@ class PublicChatChannel(
|
|||||||
) : Channel() {
|
) : Channel() {
|
||||||
var creator: User? = null
|
var creator: User? = null
|
||||||
var event: ChannelCreateEvent? = null
|
var event: ChannelCreateEvent? = null
|
||||||
|
var eventNote: Note? = null
|
||||||
|
|
||||||
var info = ChannelDataNorm(null, null, null, null)
|
var info = ChannelDataNorm(null, null, null, null)
|
||||||
var infoTags = EmptyTagList
|
var infoTags = EmptyTagList
|
||||||
@@ -61,13 +63,15 @@ class PublicChatChannel(
|
|||||||
fun updateChannelInfo(
|
fun updateChannelInfo(
|
||||||
creator: User,
|
creator: User,
|
||||||
event: ChannelCreateEvent,
|
event: ChannelCreateEvent,
|
||||||
|
eventNote: Note? = null,
|
||||||
) {
|
) {
|
||||||
this.creator = creator
|
this.creator = creator
|
||||||
this.event = event
|
this.event = event
|
||||||
|
|
||||||
this.info = event.channelInfo()
|
this.info = event.channelInfo()
|
||||||
|
|
||||||
this.infoTags = event.tags.toImmutableListOfLists()
|
this.infoTags = event.tags.toImmutableListOfLists()
|
||||||
this.updatedMetadataAt = event.createdAt
|
this.updatedMetadataAt = event.createdAt
|
||||||
|
this.eventNote = eventNote
|
||||||
|
|
||||||
updateChannelInfo()
|
updateChannelInfo()
|
||||||
}
|
}
|
||||||
@@ -77,8 +81,8 @@ class PublicChatChannel(
|
|||||||
event: ChannelMetadataEvent,
|
event: ChannelMetadataEvent,
|
||||||
) {
|
) {
|
||||||
this.creator = creator
|
this.creator = creator
|
||||||
|
|
||||||
this.info = event.channelInfo()
|
this.info = event.channelInfo()
|
||||||
|
|
||||||
this.infoTags = event.tags.toImmutableListOfLists()
|
this.infoTags = event.tags.toImmutableListOfLists()
|
||||||
this.updatedMetadataAt = event.createdAt
|
this.updatedMetadataAt = event.createdAt
|
||||||
|
|
||||||
|
|||||||
+4
@@ -22,6 +22,7 @@ package com.vitorpamplona.amethyst.model.nip53LiveActivities
|
|||||||
|
|
||||||
import androidx.compose.runtime.Stable
|
import androidx.compose.runtime.Stable
|
||||||
import com.vitorpamplona.amethyst.model.Channel
|
import com.vitorpamplona.amethyst.model.Channel
|
||||||
|
import com.vitorpamplona.amethyst.model.Note
|
||||||
import com.vitorpamplona.amethyst.model.User
|
import com.vitorpamplona.amethyst.model.User
|
||||||
import com.vitorpamplona.amethyst.ui.note.toShortDisplay
|
import com.vitorpamplona.amethyst.ui.note.toShortDisplay
|
||||||
import com.vitorpamplona.quartz.nip01Core.tags.addressables.ATag
|
import com.vitorpamplona.quartz.nip01Core.tags.addressables.ATag
|
||||||
@@ -35,6 +36,7 @@ class LiveActivitiesChannel(
|
|||||||
) : Channel() {
|
) : Channel() {
|
||||||
var creator: User? = null
|
var creator: User? = null
|
||||||
var info: LiveActivitiesEvent? = null
|
var info: LiveActivitiesEvent? = null
|
||||||
|
var infoNote: Note? = null
|
||||||
|
|
||||||
fun address() = address
|
fun address() = address
|
||||||
|
|
||||||
@@ -47,9 +49,11 @@ class LiveActivitiesChannel(
|
|||||||
fun updateChannelInfo(
|
fun updateChannelInfo(
|
||||||
creator: User,
|
creator: User,
|
||||||
channelInfo: LiveActivitiesEvent,
|
channelInfo: LiveActivitiesEvent,
|
||||||
|
channelInfoNote: Note,
|
||||||
) {
|
) {
|
||||||
this.info = channelInfo
|
this.info = channelInfo
|
||||||
this.creator = creator
|
this.creator = creator
|
||||||
|
this.infoNote = channelInfoNote
|
||||||
super.updateChannelInfo()
|
super.updateChannelInfo()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user