mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-20 07:00:30 +02:00
Clearing some warnings up
This commit is contained in:
@@ -728,11 +728,11 @@ class Account(
|
|||||||
fun isHidden(userHex: String) = userHex in hiddenUsers || userHex in transientHiddenUsers
|
fun isHidden(userHex: String) = userHex in hiddenUsers || userHex in transientHiddenUsers
|
||||||
|
|
||||||
fun followingKeySet(): Set<HexKey> {
|
fun followingKeySet(): Set<HexKey> {
|
||||||
return userProfile().cachedFollowingKeySet() ?: emptySet()
|
return userProfile().cachedFollowingKeySet()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun followingTagSet(): Set<HexKey> {
|
fun followingTagSet(): Set<HexKey> {
|
||||||
return userProfile().cachedFollowingTagSet() ?: emptySet()
|
return userProfile().cachedFollowingTagSet()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isAcceptable(user: User): Boolean {
|
fun isAcceptable(user: User): Boolean {
|
||||||
|
@@ -700,11 +700,6 @@ object LocalCache {
|
|||||||
notes.remove(it.idHex)
|
notes.remove(it.idHex)
|
||||||
// Doesn't need to clean up the replies and mentions.. Too small to matter.
|
// Doesn't need to clean up the replies and mentions.. Too small to matter.
|
||||||
|
|
||||||
// reverts the add
|
|
||||||
val mentions =
|
|
||||||
it.event?.tags()?.filter { it.firstOrNull() == "p" }?.mapNotNull { it.getOrNull(1) }
|
|
||||||
?.mapNotNull { checkGetOrCreateUser(it) }
|
|
||||||
|
|
||||||
// Counts the replies
|
// Counts the replies
|
||||||
it.replyTo?.forEach { _ ->
|
it.replyTo?.forEach { _ ->
|
||||||
it.removeReply(it)
|
it.removeReply(it)
|
||||||
|
@@ -17,7 +17,14 @@ object NostrHashtagDataSource : NostrDataSource("SingleHashtagFeed") {
|
|||||||
return TypedFilter(
|
return TypedFilter(
|
||||||
types = FeedType.values().toSet(),
|
types = FeedType.values().toSet(),
|
||||||
filter = JsonFilter(
|
filter = JsonFilter(
|
||||||
tags = mapOf("t" to listOf(hashToLoad, hashToLoad.lowercase(), hashToLoad.uppercase(), hashToLoad.capitalize())),
|
tags = mapOf(
|
||||||
|
"t" to listOf(
|
||||||
|
hashToLoad,
|
||||||
|
hashToLoad.lowercase(),
|
||||||
|
hashToLoad.uppercase(),
|
||||||
|
hashToLoad.capitalize()
|
||||||
|
)
|
||||||
|
),
|
||||||
kinds = listOf(TextNoteEvent.kind, ChannelMessageEvent.kind, LongTextNoteEvent.kind),
|
kinds = listOf(TextNoteEvent.kind, ChannelMessageEvent.kind, LongTextNoteEvent.kind),
|
||||||
limit = 200
|
limit = 200
|
||||||
)
|
)
|
||||||
|
@@ -7,7 +7,6 @@ import com.vitorpamplona.amethyst.service.relays.EOSETime
|
|||||||
import com.vitorpamplona.amethyst.service.relays.FeedType
|
import com.vitorpamplona.amethyst.service.relays.FeedType
|
||||||
import com.vitorpamplona.amethyst.service.relays.JsonFilter
|
import com.vitorpamplona.amethyst.service.relays.JsonFilter
|
||||||
import com.vitorpamplona.amethyst.service.relays.TypedFilter
|
import com.vitorpamplona.amethyst.service.relays.TypedFilter
|
||||||
import java.util.Date
|
|
||||||
|
|
||||||
object NostrSingleEventDataSource : NostrDataSource("SingleEventFeed") {
|
object NostrSingleEventDataSource : NostrDataSource("SingleEventFeed") {
|
||||||
private var eventsToWatch = setOf<Note>()
|
private var eventsToWatch = setOf<Note>()
|
||||||
@@ -20,8 +19,6 @@ object NostrSingleEventDataSource : NostrDataSource("SingleEventFeed") {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
val now = Date().time / 1000
|
|
||||||
|
|
||||||
return addressesToWatch.mapNotNull {
|
return addressesToWatch.mapNotNull {
|
||||||
it.address()?.let { aTag ->
|
it.address()?.let { aTag ->
|
||||||
TypedFilter(
|
TypedFilter(
|
||||||
@@ -49,8 +46,6 @@ object NostrSingleEventDataSource : NostrDataSource("SingleEventFeed") {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
val now = Date().time / 1000
|
|
||||||
|
|
||||||
return addressesToWatch.mapNotNull {
|
return addressesToWatch.mapNotNull {
|
||||||
it.address()?.let { aTag ->
|
it.address()?.let { aTag ->
|
||||||
TypedFilter(
|
TypedFilter(
|
||||||
|
@@ -25,7 +25,7 @@ object NostrThreadDataSource : NostrDataSource("SingleThreadFeed") {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
val loadEventsChannel = requestNewChannel() { eoseTime, relay ->
|
val loadEventsChannel = requestNewChannel() { _, _ ->
|
||||||
// Many relays operate with limits in the amount of filters.
|
// Many relays operate with limits in the amount of filters.
|
||||||
// As information comes, the filters will be rotated to get more data.
|
// As information comes, the filters will be rotated to get more data.
|
||||||
invalidateFilters()
|
invalidateFilters()
|
||||||
|
@@ -9,21 +9,21 @@ import com.vitorpamplona.amethyst.service.nip19.Nip19
|
|||||||
|
|
||||||
class NewMessageTagger(var channel: Channel?, var mentions: List<User>?, var replyTos: List<Note>?, var message: String) {
|
class NewMessageTagger(var channel: Channel?, var mentions: List<User>?, var replyTos: List<Note>?, var message: String) {
|
||||||
|
|
||||||
open fun addUserToMentions(user: User) {
|
fun addUserToMentions(user: User) {
|
||||||
mentions = if (mentions?.contains(user) == true) mentions else mentions?.plus(user) ?: listOf(user)
|
mentions = if (mentions?.contains(user) == true) mentions else mentions?.plus(user) ?: listOf(user)
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun addNoteToReplyTos(note: Note) {
|
fun addNoteToReplyTos(note: Note) {
|
||||||
note.author?.let { addUserToMentions(it) }
|
note.author?.let { addUserToMentions(it) }
|
||||||
replyTos = if (replyTos?.contains(note) == true) replyTos else replyTos?.plus(note) ?: listOf(note)
|
replyTos = if (replyTos?.contains(note) == true) replyTos else replyTos?.plus(note) ?: listOf(note)
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun tagIndex(user: User): Int {
|
fun tagIndex(user: User): Int {
|
||||||
// Postr Events assembles replies before mentions in the tag order
|
// Postr Events assembles replies before mentions in the tag order
|
||||||
return (if (channel != null) 1 else 0) + (replyTos?.size ?: 0) + (mentions?.indexOf(user) ?: 0)
|
return (if (channel != null) 1 else 0) + (replyTos?.size ?: 0) + (mentions?.indexOf(user) ?: 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun tagIndex(note: Note): Int {
|
fun tagIndex(note: Note): Int {
|
||||||
// Postr Events assembles replies before mentions in the tag order
|
// Postr Events assembles replies before mentions in the tag order
|
||||||
return (if (channel != null) 1 else 0) + (replyTos?.indexOf(note) ?: 0)
|
return (if (channel != null) 1 else 0) + (replyTos?.indexOf(note) ?: 0)
|
||||||
}
|
}
|
||||||
|
@@ -7,7 +7,6 @@ import androidx.compose.material.icons.Icons
|
|||||||
import androidx.compose.material.icons.filled.Delete
|
import androidx.compose.material.icons.filled.Delete
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.text.input.KeyboardCapitalization
|
import androidx.compose.ui.text.input.KeyboardCapitalization
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
@@ -15,15 +14,6 @@ import com.vitorpamplona.amethyst.R
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun NewPollOption(pollViewModel: NewPostViewModel, optionIndex: Int) {
|
fun NewPollOption(pollViewModel: NewPostViewModel, optionIndex: Int) {
|
||||||
val colorInValid = TextFieldDefaults.outlinedTextFieldColors(
|
|
||||||
focusedBorderColor = MaterialTheme.colors.error,
|
|
||||||
unfocusedBorderColor = Color.Red
|
|
||||||
)
|
|
||||||
val colorValid = TextFieldDefaults.outlinedTextFieldColors(
|
|
||||||
focusedBorderColor = MaterialTheme.colors.primary,
|
|
||||||
unfocusedBorderColor = MaterialTheme.colors.onSurface.copy(alpha = 0.32f)
|
|
||||||
)
|
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
val deleteIcon: @Composable (() -> Unit) = {
|
val deleteIcon: @Composable (() -> Unit) = {
|
||||||
IconButton(
|
IconButton(
|
||||||
|
@@ -116,7 +116,7 @@ fun NewPollView(onClose: () -> Unit, baseReplyTo: Note? = null, quote: Note? = n
|
|||||||
Text(stringResource(R.string.poll_heading_required))
|
Text(stringResource(R.string.poll_heading_required))
|
||||||
// NewPollRecipientsField(pollViewModel, account)
|
// NewPollRecipientsField(pollViewModel, account)
|
||||||
NewPollPrimaryDescription(pollViewModel)
|
NewPollPrimaryDescription(pollViewModel)
|
||||||
pollViewModel.pollOptions.values.forEachIndexed { index, element ->
|
pollViewModel.pollOptions.values.forEachIndexed { index, _ ->
|
||||||
NewPollOption(pollViewModel, index)
|
NewPollOption(pollViewModel, index)
|
||||||
}
|
}
|
||||||
Button(
|
Button(
|
||||||
@@ -150,7 +150,7 @@ fun NewPollView(onClose: () -> Unit, baseReplyTo: Note? = null, quote: Note? = n
|
|||||||
itemsIndexed(
|
itemsIndexed(
|
||||||
userSuggestions,
|
userSuggestions,
|
||||||
key = { _, item -> item.pubkeyHex }
|
key = { _, item -> item.pubkeyHex }
|
||||||
) { index, item ->
|
) { _, item ->
|
||||||
UserLine(item, account) {
|
UserLine(item, account) {
|
||||||
pollViewModel.autocompleteWithUser(item)
|
pollViewModel.autocompleteWithUser(item)
|
||||||
}
|
}
|
||||||
|
@@ -167,7 +167,7 @@ fun NewPostView(onClose: () -> Unit, baseReplyTo: Note? = null, quote: Note? = n
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (postViewModel.wantsPoll) {
|
if (postViewModel.wantsPoll) {
|
||||||
postViewModel.pollOptions.values.forEachIndexed { index, element ->
|
postViewModel.pollOptions.values.forEachIndexed { index, _ ->
|
||||||
NewPollOption(postViewModel, index)
|
NewPollOption(postViewModel, index)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,7 +189,7 @@ fun NewPostView(onClose: () -> Unit, baseReplyTo: Note? = null, quote: Note? = n
|
|||||||
val user = postViewModel.account?.userProfile()
|
val user = postViewModel.account?.userProfile()
|
||||||
val lud16 = user?.info?.lnAddress()
|
val lud16 = user?.info?.lnAddress()
|
||||||
|
|
||||||
if (lud16 != null && user != null && postViewModel.wantsInvoice) {
|
if (lud16 != null && postViewModel.wantsInvoice) {
|
||||||
Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.padding(vertical = 5.dp)) {
|
Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.padding(vertical = 5.dp)) {
|
||||||
InvoiceRequest(
|
InvoiceRequest(
|
||||||
lud16,
|
lud16,
|
||||||
|
@@ -180,7 +180,7 @@ fun RichTextViewer(
|
|||||||
navController
|
navController
|
||||||
)
|
)
|
||||||
} else if (hashTagsPattern.matcher(word).matches()) {
|
} else if (hashTagsPattern.matcher(word).matches()) {
|
||||||
HashTag(word, accountViewModel, navController)
|
HashTag(word, navController)
|
||||||
} else {
|
} else {
|
||||||
Text(
|
Text(
|
||||||
text = "$word ",
|
text = "$word ",
|
||||||
@@ -193,6 +193,7 @@ fun RichTextViewer(
|
|||||||
val url = matcher.group(1) // url
|
val url = matcher.group(1) // url
|
||||||
val additionalChars = matcher.group(4) ?: "" // additional chars
|
val additionalChars = matcher.group(4) ?: "" // additional chars
|
||||||
|
|
||||||
|
if (url != null) {
|
||||||
ClickableUrl(url, "https://$url")
|
ClickableUrl(url, "https://$url")
|
||||||
Text("$additionalChars ")
|
Text("$additionalChars ")
|
||||||
} else {
|
} else {
|
||||||
@@ -201,6 +202,12 @@ fun RichTextViewer(
|
|||||||
style = LocalTextStyle.current.copy(textDirection = TextDirection.Content)
|
style = LocalTextStyle.current.copy(textDirection = TextDirection.Content)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Text(
|
||||||
|
text = "$word ",
|
||||||
|
style = LocalTextStyle.current.copy(textDirection = TextDirection.Content)
|
||||||
|
)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (urlSet.contains(word)) {
|
if (urlSet.contains(word)) {
|
||||||
ClickableUrl("$word ", word)
|
ClickableUrl("$word ", word)
|
||||||
@@ -237,7 +244,7 @@ fun RichTextViewer(
|
|||||||
navController
|
navController
|
||||||
)
|
)
|
||||||
} else if (hashTagsPattern.matcher(word).matches()) {
|
} else if (hashTagsPattern.matcher(word).matches()) {
|
||||||
HashTag(word, accountViewModel, navController)
|
HashTag(word, navController)
|
||||||
} else {
|
} else {
|
||||||
Text(
|
Text(
|
||||||
text = "$word ",
|
text = "$word ",
|
||||||
@@ -250,6 +257,7 @@ fun RichTextViewer(
|
|||||||
val url = matcher.group(1) // url
|
val url = matcher.group(1) // url
|
||||||
val additionalChars = matcher.group(4) ?: "" // additional chars
|
val additionalChars = matcher.group(4) ?: "" // additional chars
|
||||||
|
|
||||||
|
if (url != null) {
|
||||||
ClickableUrl(url, "https://$url")
|
ClickableUrl(url, "https://$url")
|
||||||
Text("$additionalChars ")
|
Text("$additionalChars ")
|
||||||
} else {
|
} else {
|
||||||
@@ -258,6 +266,12 @@ fun RichTextViewer(
|
|||||||
style = LocalTextStyle.current.copy(textDirection = TextDirection.Content)
|
style = LocalTextStyle.current.copy(textDirection = TextDirection.Content)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Text(
|
||||||
|
text = "$word ",
|
||||||
|
style = LocalTextStyle.current.copy(textDirection = TextDirection.Content)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -328,7 +342,7 @@ fun BechLink(word: String, canPreview: Boolean, backgroundColor: Color, accountV
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun HashTag(word: String, accountViewModel: AccountViewModel, navController: NavController) {
|
fun HashTag(word: String, navController: NavController) {
|
||||||
var tagSuffixPair by remember { mutableStateOf<Pair<String, String?>?>(null) }
|
var tagSuffixPair by remember { mutableStateOf<Pair<String, String?>?>(null) }
|
||||||
|
|
||||||
LaunchedEffect(key1 = word) {
|
LaunchedEffect(key1 = word) {
|
||||||
|
@@ -41,24 +41,24 @@ fun UrlPreviewCard(
|
|||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
Column {
|
Column {
|
||||||
val url = URL(previewInfo.url)
|
val validatedUrl = URL(previewInfo.url)
|
||||||
|
|
||||||
// correctly treating relative images
|
// correctly treating relative images
|
||||||
val imageUrl = if (previewInfo.image.startsWith("/")) {
|
val imageUrl = if (previewInfo.image.startsWith("/")) {
|
||||||
URL(url, previewInfo.image).toString()
|
URL(validatedUrl, previewInfo.image).toString()
|
||||||
} else {
|
} else {
|
||||||
previewInfo.image
|
previewInfo.image
|
||||||
}
|
}
|
||||||
|
|
||||||
AsyncImage(
|
AsyncImage(
|
||||||
model = imageUrl,
|
model = imageUrl,
|
||||||
contentDescription = stringResource(R.string.preview_card_image_for, url),
|
contentDescription = stringResource(R.string.preview_card_image_for, validatedUrl),
|
||||||
contentScale = ContentScale.FillWidth,
|
contentScale = ContentScale.FillWidth,
|
||||||
modifier = Modifier.fillMaxWidth()
|
modifier = Modifier.fillMaxWidth()
|
||||||
)
|
)
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
text = url.host,
|
text = validatedUrl.host,
|
||||||
style = MaterialTheme.typography.caption,
|
style = MaterialTheme.typography.caption,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
|
Reference in New Issue
Block a user