mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-03-26 17:52:29 +01:00
Merge branch 'main' into gallery
This commit is contained in:
commit
a0a8010305
@ -49,6 +49,7 @@ import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.livedata.observeAsState
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
@ -71,6 +72,7 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.TextSpinner
|
||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.TitleExplainer
|
||||
import com.vitorpamplona.amethyst.ui.stringRes
|
||||
import com.vitorpamplona.amethyst.ui.theme.placeholderText
|
||||
import com.vitorpamplona.quartz.events.FileServersEvent
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlinx.coroutines.CancellationException
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@ -189,8 +191,25 @@ fun ImageVideoPost(
|
||||
postViewModel: NewMediaModel,
|
||||
accountViewModel: AccountViewModel,
|
||||
) {
|
||||
val listOfNip96ServersNote =
|
||||
accountViewModel.account
|
||||
.getFileServersNote()
|
||||
.live()
|
||||
.metadata
|
||||
.observeAsState()
|
||||
|
||||
val fileServers =
|
||||
Nip96MediaServers.DEFAULT.map { ServerOption(it, false) } +
|
||||
(
|
||||
(listOfNip96ServersNote.value?.note?.event as? FileServersEvent)?.servers()?.map {
|
||||
ServerOption(
|
||||
Nip96MediaServers.ServerName(
|
||||
it,
|
||||
it,
|
||||
),
|
||||
false,
|
||||
)
|
||||
} ?: Nip96MediaServers.DEFAULT.map { ServerOption(it, false) }
|
||||
) +
|
||||
listOf(
|
||||
ServerOption(
|
||||
Nip96MediaServers.ServerName(
|
||||
|
@ -168,6 +168,7 @@ import com.vitorpamplona.amethyst.ui.theme.placeholderText
|
||||
import com.vitorpamplona.amethyst.ui.theme.replyModifier
|
||||
import com.vitorpamplona.amethyst.ui.theme.subtleBorder
|
||||
import com.vitorpamplona.quartz.events.ClassifiedsEvent
|
||||
import com.vitorpamplona.quartz.events.FileServersEvent
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlinx.coroutines.CancellationException
|
||||
@ -1620,8 +1621,25 @@ fun ImageVideoDescription(
|
||||
val isImage = mediaType.startsWith("image")
|
||||
val isVideo = mediaType.startsWith("video")
|
||||
|
||||
val listOfNip96ServersNote =
|
||||
accountViewModel.account
|
||||
.getFileServersNote()
|
||||
.live()
|
||||
.metadata
|
||||
.observeAsState()
|
||||
|
||||
val fileServers =
|
||||
Nip96MediaServers.DEFAULT.map { ServerOption(it, false) } +
|
||||
(
|
||||
(listOfNip96ServersNote.value?.note?.event as? FileServersEvent)?.servers()?.map {
|
||||
ServerOption(
|
||||
Nip96MediaServers.ServerName(
|
||||
it,
|
||||
it,
|
||||
),
|
||||
false,
|
||||
)
|
||||
} ?: Nip96MediaServers.DEFAULT.map { ServerOption(it, false) }
|
||||
) +
|
||||
listOf(
|
||||
ServerOption(
|
||||
Nip96MediaServers.ServerName(
|
||||
|
@ -24,7 +24,7 @@ kotlin = "1.9.24"
|
||||
kotlinxCollectionsImmutable = "0.3.7"
|
||||
languageId = "17.0.5"
|
||||
lazysodiumAndroid = "5.1.0"
|
||||
lifecycleRuntimeKtx = "2.8.2"
|
||||
lifecycleRuntimeKtx = "2.8.3"
|
||||
lightcompressor = "1.3.2"
|
||||
markdown = "077a2cde64"
|
||||
media3 = "1.3.1"
|
||||
|
@ -37,34 +37,30 @@ class FileServersEvent(
|
||||
) : BaseAddressableEvent(id, pubKey, createdAt, KIND, tags, content, sig) {
|
||||
override fun dTag() = FIXED_D_TAG
|
||||
|
||||
fun servers(): List<String> {
|
||||
return tags.mapNotNull {
|
||||
if (it.size > 1 && it[0] == "relay") {
|
||||
fun servers(): List<String> =
|
||||
tags.mapNotNull {
|
||||
if (it.size > 1 && it[0] == "server") {
|
||||
it[1]
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val KIND = 10096
|
||||
const val FIXED_D_TAG = ""
|
||||
const val ALT = "File servers used by the author"
|
||||
|
||||
fun createAddressATag(pubKey: HexKey): ATag {
|
||||
return ATag(KIND, pubKey, FIXED_D_TAG, null)
|
||||
}
|
||||
fun createAddressATag(pubKey: HexKey): ATag = ATag(KIND, pubKey, FIXED_D_TAG, null)
|
||||
|
||||
fun createAddressTag(pubKey: HexKey): String {
|
||||
return ATag.assembleATag(KIND, pubKey, FIXED_D_TAG)
|
||||
}
|
||||
fun createAddressTag(pubKey: HexKey): String = ATag.assembleATag(KIND, pubKey, FIXED_D_TAG)
|
||||
|
||||
fun createTagArray(servers: List<String>): Array<Array<String>> {
|
||||
return servers.map {
|
||||
arrayOf("server", it)
|
||||
}.plusElement(arrayOf("alt", "Relay list to use for Search")).toTypedArray()
|
||||
}
|
||||
fun createTagArray(servers: List<String>): Array<Array<String>> =
|
||||
servers
|
||||
.map {
|
||||
arrayOf("server", it)
|
||||
}.plusElement(arrayOf("alt", "Relay list to use for Search"))
|
||||
.toTypedArray()
|
||||
|
||||
fun updateRelayList(
|
||||
earlierVersion: FileServersEvent,
|
||||
@ -74,11 +70,13 @@ class FileServersEvent(
|
||||
onReady: (FileServersEvent) -> Unit,
|
||||
) {
|
||||
val tags =
|
||||
earlierVersion.tags.filter { it[0] != "server" }.plus(
|
||||
relays.map {
|
||||
arrayOf("server", it)
|
||||
},
|
||||
).toTypedArray()
|
||||
earlierVersion.tags
|
||||
.filter { it[0] != "server" }
|
||||
.plus(
|
||||
relays.map {
|
||||
arrayOf("server", it)
|
||||
},
|
||||
).toTypedArray()
|
||||
|
||||
signer.sign(createdAt, KIND, tags, earlierVersion.content, onReady)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user