From ffd43e448bc1687cd4847f1589f37091748a4e37 Mon Sep 17 00:00:00 2001 From: David Kaspar Date: Fri, 15 Nov 2024 12:54:59 +0100 Subject: [PATCH 1/6] filter out drafts that are not same author as current account --- .../amethyst/ui/screen/loggedIn/threadview/ThreadFeedView.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/ThreadFeedView.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/ThreadFeedView.kt index fb55ef542..28016b70b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/ThreadFeedView.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/ThreadFeedView.kt @@ -268,7 +268,7 @@ fun RenderThreadFeed( contentPadding = FeedPadding, state = listState, ) { - itemsIndexed(items.list, key = { _, item -> item.idHex }) { index, item -> + itemsIndexed(items.list.filter { !it.isDraft() || (it.author?.pubkeyHex == accountViewModel.account.userProfile().pubkeyHex) }, key = { _, item -> item.idHex }) { index, item -> val level = viewModel.levelFlowForItem(item).collectAsStateWithLifecycle(0) val modifier = From 82164769165a6a647e7f82e286eed77046ce470d Mon Sep 17 00:00:00 2001 From: David Kaspar Date: Sat, 16 Nov 2024 08:47:36 +0100 Subject: [PATCH 2/6] cleaner code, fewer warnings --- .../ui/screen/loggedIn/threadview/ThreadFeedView.kt | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/ThreadFeedView.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/ThreadFeedView.kt index 28016b70b..6fd7de78a 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/ThreadFeedView.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/ThreadFeedView.kt @@ -274,7 +274,6 @@ fun RenderThreadFeed( val modifier = Modifier .drawReplyLevel( - note = item, level = level, color = MaterialTheme.colorScheme.placeholderText, selected = @@ -322,7 +321,6 @@ fun RenderThreadFeed( // Creates a Zebra pattern where each bar is a reply level. fun Modifier.drawReplyLevel( - note: Note, level: State, color: Color, selected: Color, @@ -662,9 +660,8 @@ private fun FullBleedNoteCompose( } } - val noteEvent = baseNote.event - val zapSplits = remember(noteEvent) { noteEvent?.hasZapSplitSetup() ?: false } - if (zapSplits && noteEvent != null) { + val zapSplits = remember(noteEvent) { noteEvent.hasZapSplitSetup() } + if (zapSplits) { Spacer(modifier = DoubleVertSpacer) Row( modifier = Modifier.padding(horizontal = 12.dp), From f16143bec3dc967202125882f148981c12d3bcf4 Mon Sep 17 00:00:00 2001 From: David Kaspar Date: Sat, 16 Nov 2024 09:29:45 +0100 Subject: [PATCH 3/6] cleaner code, fewer warnings --- .../loggedIn/threadview/ThreadFeedView.kt | 52 +++++++++++-------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/ThreadFeedView.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/ThreadFeedView.kt index 6fd7de78a..9165b0c75 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/ThreadFeedView.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/ThreadFeedView.kt @@ -242,9 +242,9 @@ fun RenderThreadFeed( // In that case, this screen will open with 0-1 items, and the scrollToItem below // will not change the state of the screen (too few items, scroll is not available) // as the app loads the reaming of the thread the position of the reply changes - // and becuase there wasn't a possibility to scroll before and now there is one, + // and because there wasn't a possibility to scroll before and now there is one, // the screen stays at the top. Once the thread has enough replies, the lazy column - // updates with new items correctly. It just needs a few items to start the scrool. + // updates with new items correctly. It just needs a few items to start the scroll. // // This hack allows the list 1 second to fill up with more // records before setting up the position on the feed. @@ -482,14 +482,22 @@ private fun FullBleedNoteCompose( Spacer(modifier = Modifier.height(10.dp)) - if (noteEvent is BadgeDefinitionEvent) { - BadgeDisplay(baseNote = baseNote) - } else if (noteEvent is LongTextNoteEvent) { - RenderLongFormHeaderForThread(noteEvent) - } else if (noteEvent is WikiNoteEvent) { - RenderWikiHeaderForThread(noteEvent, accountViewModel, nav) - } else if (noteEvent is ClassifiedsEvent) { - RenderClassifiedsReaderForThread(noteEvent, baseNote, accountViewModel, nav) + when (noteEvent) { + is BadgeDefinitionEvent -> { + BadgeDisplay(baseNote = baseNote) + } + + is LongTextNoteEvent -> { + RenderLongFormHeaderForThread(noteEvent) + } + + is WikiNoteEvent -> { + RenderWikiHeaderForThread(noteEvent, accountViewModel, nav) + } + + is ClassifiedsEvent -> { + RenderClassifiedsReaderForThread(noteEvent, baseNote, accountViewModel, nav) + } } Row( @@ -510,11 +518,11 @@ private fun FullBleedNoteCompose( nav = nav, ) } else if (noteEvent is VideoEvent) { - VideoDisplay(baseNote, false, true, backgroundColor, false, accountViewModel, nav) + VideoDisplay(baseNote, makeItShort = false, canPreview = true, backgroundColor = backgroundColor, isFiniteHeight = false, accountViewModel = accountViewModel, nav = nav) } else if (noteEvent is FileHeaderEvent) { - FileHeaderDisplay(baseNote, true, false, accountViewModel) + FileHeaderDisplay(baseNote, roundedCorner = true, isFiniteHeight = false, accountViewModel = accountViewModel) } else if (noteEvent is FileStorageHeaderEvent) { - FileStorageHeaderDisplay(baseNote, true, false, accountViewModel) + FileStorageHeaderDisplay(baseNote, roundedCorner = true, isFiniteHeight = false, accountViewModel = accountViewModel) } else if (noteEvent is PeopleListEvent) { DisplayPeopleList(baseNote, backgroundColor, accountViewModel, nav) } else if (noteEvent is AudioTrackEvent) { @@ -561,9 +569,9 @@ private fun FullBleedNoteCompose( } else if (noteEvent is GitRepositoryEvent) { RenderGitRepositoryEvent(baseNote, accountViewModel, nav) } else if (noteEvent is GitPatchEvent) { - RenderGitPatchEvent(baseNote, false, true, quotesLeft = 3, backgroundColor, accountViewModel, nav) + RenderGitPatchEvent(baseNote, makeItShort = false, canPreview = true, quotesLeft = 3, backgroundColor = backgroundColor, accountViewModel = accountViewModel, nav = nav) } else if (noteEvent is GitIssueEvent) { - RenderGitIssueEvent(baseNote, false, true, quotesLeft = 3, backgroundColor, accountViewModel, nav) + RenderGitIssueEvent(baseNote, makeItShort = false, canPreview = true, quotesLeft = 3, backgroundColor = backgroundColor, accountViewModel = accountViewModel, nav = nav) } else if (noteEvent is AppDefinitionEvent) { RenderAppDefinition(baseNote, accountViewModel, nav) } else if (noteEvent is DraftEvent) { @@ -670,7 +678,7 @@ private fun FullBleedNoteCompose( } } - ReactionsRow(baseNote, true, true, editState, accountViewModel, nav) + ReactionsRow(baseNote, showReactionDetail = true, addPadding = true, editState = editState, accountViewModel = accountViewModel, nav = nav) } } @@ -922,14 +930,14 @@ private fun RenderWikiHeaderForThreadPreview() { RenderWikiHeaderForThread(noteEvent = event, accountViewModel = accountViewModel, nav) RenderTextEvent( baseNote!!, - false, - true, + makeItShort = false, + canPreview = true, quotesLeft = 3, unPackReply = false, - backgroundColor, - editState, - accountViewModel, - nav, + backgroundColor = backgroundColor, + editState = editState, + accountViewModel = accountViewModel, + nav = nav, ) } } From 6c3200a9ccc6bf1d757c6d9e12a7b4395df162be Mon Sep 17 00:00:00 2001 From: David Kaspar Date: Sat, 16 Nov 2024 10:34:01 +0100 Subject: [PATCH 4/6] cleaner code, change cascading ifs to when --- .../loggedIn/threadview/ThreadFeedView.kt | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/ThreadFeedView.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/ThreadFeedView.kt index 9165b0c75..d79a6974b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/ThreadFeedView.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/ThreadFeedView.kt @@ -483,21 +483,10 @@ private fun FullBleedNoteCompose( Spacer(modifier = Modifier.height(10.dp)) when (noteEvent) { - is BadgeDefinitionEvent -> { - BadgeDisplay(baseNote = baseNote) - } - - is LongTextNoteEvent -> { - RenderLongFormHeaderForThread(noteEvent) - } - - is WikiNoteEvent -> { - RenderWikiHeaderForThread(noteEvent, accountViewModel, nav) - } - - is ClassifiedsEvent -> { - RenderClassifiedsReaderForThread(noteEvent, baseNote, accountViewModel, nav) - } + is BadgeDefinitionEvent -> BadgeDisplay(baseNote = baseNote) + is LongTextNoteEvent -> RenderLongFormHeaderForThread(noteEvent) + is WikiNoteEvent -> RenderWikiHeaderForThread(noteEvent, accountViewModel, nav) + is ClassifiedsEvent -> RenderClassifiedsReaderForThread(noteEvent, baseNote, accountViewModel, nav) } Row( From 4a590d67a640ed2c34ef18d494bb8054c874f3d3 Mon Sep 17 00:00:00 2001 From: David Kaspar Date: Sun, 17 Nov 2024 10:48:03 +0100 Subject: [PATCH 5/6] move filtering of "not your drafts" to ThreadFeedFilter --- .../amethyst/ui/dal/ThreadFeedFilter.kt | 14 +++++++++++--- .../screen/loggedIn/threadview/ThreadFeedView.kt | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/dal/ThreadFeedFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/dal/ThreadFeedFilter.kt index 21374035d..bc80e6fb2 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/dal/ThreadFeedFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/dal/ThreadFeedFilter.kt @@ -27,11 +27,12 @@ import com.vitorpamplona.amethyst.model.Note import com.vitorpamplona.amethyst.model.ThreadAssembler import com.vitorpamplona.amethyst.model.ThreadLevelCalculator import com.vitorpamplona.quartz.utils.TimeUtils +import kotlinx.collections.immutable.toImmutableSet @Immutable class ThreadFeedFilter( val account: Account, - val noteId: String, + private val noteId: String, ) : FeedFilter() { override fun feedKey(): String = noteId @@ -40,7 +41,14 @@ class ThreadFeedFilter( val followingKeySet = account.liveKind3Follows.value.authors val eventsToWatch = ThreadAssembler().findThreadFor(noteId) ?: return emptyList() - val eventsInHex = eventsToWatch.allNotes.map { it.idHex }.toSet() + // Filter out drafts made by other accounts on device + val filteredEvents = + eventsToWatch.allNotes + .filter { !it.isDraft() || (it.author?.pubkeyHex == account.userProfile().pubkeyHex) } + .toImmutableSet() + val filteredThreadInfo = ThreadAssembler.ThreadInfo(eventsToWatch.root, filteredEvents) + + val eventsInHex = filteredThreadInfo.allNotes.map { it.idHex }.toSet() val now = TimeUtils.now() // Currently orders by date of each event, descending, at each level of the reply stack @@ -57,6 +65,6 @@ class ThreadFeedFilter( ).signature } - return eventsToWatch.allNotes.sortedWith(order) + return filteredThreadInfo.allNotes.sortedWith(order) } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/ThreadFeedView.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/ThreadFeedView.kt index d79a6974b..da2f81c48 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/ThreadFeedView.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/ThreadFeedView.kt @@ -268,7 +268,7 @@ fun RenderThreadFeed( contentPadding = FeedPadding, state = listState, ) { - itemsIndexed(items.list.filter { !it.isDraft() || (it.author?.pubkeyHex == accountViewModel.account.userProfile().pubkeyHex) }, key = { _, item -> item.idHex }) { index, item -> + itemsIndexed(items.list, key = { _, item -> item.idHex }) { index, item -> val level = viewModel.levelFlowForItem(item).collectAsStateWithLifecycle(0) val modifier = From fab6c65e98717240c27cfd6abbff400715882062 Mon Sep 17 00:00:00 2001 From: Crowdin Bot Date: Mon, 18 Nov 2024 13:22:15 +0000 Subject: [PATCH 6/6] New Crowdin translations by GitHub Action --- amethyst/src/main/res/values-hi-rIN/strings.xml | 2 ++ amethyst/src/main/res/values-hu/strings.xml | 2 ++ amethyst/src/main/res/values-nl/strings.xml | 2 ++ amethyst/src/main/res/values-pl-rPL/strings.xml | 2 ++ 4 files changed, 8 insertions(+) diff --git a/amethyst/src/main/res/values-hi-rIN/strings.xml b/amethyst/src/main/res/values-hi-rIN/strings.xml index e94db4a15..b01302505 100644 --- a/amethyst/src/main/res/values-hi-rIN/strings.xml +++ b/amethyst/src/main/res/values-hi-rIN/strings.xml @@ -547,6 +547,8 @@ अवलम्बन करनेवाले ग्राहक ज्सापों को आगे भेजेंगे लै॰जाल पता को अथवा नीचे के उपयोगकर्ता परिचय को तथा आपके तक नहीं स्थान अनावृत करें ऐसे आपका भूगोलिक स्थान विभेदक जोडता है पत्र में। जनता जान जाएगी कि आप वर्तमान स्थान से ५ कि॰मे॰ (३ मी॰) की दूरी के अन्दर हैं + स्थान प्राप्त किया जा रहा है + स्थान प्राप्त करने की अनुमति नहीं आपके विषयवस्तु दिखाने से पूर्व संवेदनशील विषयवस्तु चेतावनी जोडता है। यह आदर्श है किसी कार्यालय अनुचित विषयवस्तु के लिए अथवा जो कुछ लोगों के लिए आपत्तिजनक अथवा व्याकुल करनेवाला लग सकता है नयी सुविधा इस कार्यशैली सक्षम करने के लिए अमेथिस्ट के द्वारा निप॰-१७ संदेश (उपहारकोषयुक्त, आच्छादित सीधा तथा झुण्ड संदेश) भेजना पडेगा। यह निप॰-१७ नया है तथा अनेक ग्राहक इसे कार्यान्वित किया नहीं अब तक। सुनिश्चित करें कि प्राप्तकर्ता एक अनुकूल ग्राहक का प्रयोग कर रहे हैं। diff --git a/amethyst/src/main/res/values-hu/strings.xml b/amethyst/src/main/res/values-hu/strings.xml index 343a3193d..a3c08b9d3 100644 --- a/amethyst/src/main/res/values-hu/strings.xml +++ b/amethyst/src/main/res/values-hu/strings.xml @@ -546,6 +546,8 @@ A funkciót támogató kliensek a Zap-eket az Ön tárcája helyett, az alábbi LN-címre vagy felhasználói profilra továbbítják A Hely megjelenítése mint A bejegyzéshez az Ön tartózkodási helyének Geohash-ét hozzáadja. A közönség tudni fogja, hogy az aktuális helytől 5 km-en (3 mérföldön) belül van + Hely betöltése + Helymeghatározás nincs engedélyezve A kényes tartalom miatt, azon megjelenítése előtt figyelmeztetést ad. Ez ideális minden Felnőtt tartalomhoz vagy olyan tartalomhoz, amelyet egyesek sértőnek vagy zavarónak találhatnak Új funkció Az Amethystnek ennek a módnak az aktiválásához NIP-17 üzenetet kell küldenie (GiftWrapped, Zárolt direkt és csoportos üzeneteket). A NIP-17 új, és a legtöbb kliens még nem implementálta. Győződj meg arról, hogy a fogadó fél kompatibilis klienst használ. diff --git a/amethyst/src/main/res/values-nl/strings.xml b/amethyst/src/main/res/values-nl/strings.xml index eb10f4c5b..6ee3196e7 100644 --- a/amethyst/src/main/res/values-nl/strings.xml +++ b/amethyst/src/main/res/values-nl/strings.xml @@ -547,6 +547,8 @@ Ondersteunende clients sturen zaps door naar het onderstaande LN-adres of gebruikersprofiel in plaats van naar het jouwe Locatie weergeven als Voegt een Geohash van je locatie toe aan het bericht. Het publiek weet dat je binnen 5 km (3mi) van de huidige locatie bent. + Locatie laden + Geen locatiemachtigingen Voegt een waarschuwing voor gevoelige inhoud toe voordat je inhoud wordt weergegeven. Dit is ideaal voor NSFW-inhoud of inhoud die sommige mensen beledigend of verontrustend vinden. Nieuwe functie Voor het activeren van deze modus is Amethyst nodig om een NIP-17 bericht te versturen. NIP-17 is nieuw en de meeste clients hebben deze nog niet geïmplementeerd. Zorg ervoor dat de ontvanger een compatibele client gebruikt. diff --git a/amethyst/src/main/res/values-pl-rPL/strings.xml b/amethyst/src/main/res/values-pl-rPL/strings.xml index abf5c440e..841f967c5 100644 --- a/amethyst/src/main/res/values-pl-rPL/strings.xml +++ b/amethyst/src/main/res/values-pl-rPL/strings.xml @@ -547,6 +547,8 @@ Wspierający klient podzieli i przekaże zapy na LNAdres lub profil użytkownika poniżej zamiast Ciebie Wyświetl lokalizację jako Dodaje Geohash twojej lokalizacji do wpisu. Użytkownicy będą wiedzieli, że jesteś mniej niż 5 km od bieżącej lokalizacji + Pobieranie lokalizacji + Brak dostępu do lokalizacji Dodaje ostrzeżenie o wrażliwych treściach przed wyświetleniem treści. Jest to idealne dla dowolnych treści NSFW lub treści, które niektóre osoby mogą uznać za obraźliwe lub przeszkadzające Nowa Funkcjonalność Aktywacja tego trybu wymaga wysłania wiadomości NIP-17 przez Ametyst. (Prezent, Zapieczętowane wiadomości bezpośrednie i grupowe). NIP-17 jest nowy, a większość klientów jeszcze go nie zaimplementowała. Upewnij się, że odbiorca używa kompatybilnego klienta.