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