Merge branch 'main' into gallery

pull/957/head
believethehype 2024-07-02 08:50:44 +02:00 zatwierdzone przez GitHub
commit a0a8010305
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
4 zmienionych plików z 58 dodań i 23 usunięć

Wyświetl plik

@ -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(

Wyświetl plik

@ -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(

Wyświetl plik

@ -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"

Wyświetl plik

@ -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)
}