Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorpamplona committed Nov 18, 2024
2 parents 192a43d + 488286c commit 04d6da2
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Note>() {
override fun feedKey(): String = noteId

Expand All @@ -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
Expand All @@ -57,6 +65,6 @@ class ThreadFeedFilter(
).signature
}

return eventsToWatch.allNotes.sortedWith(order)
return filteredThreadInfo.allNotes.sortedWith(order)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,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.
Expand Down Expand Up @@ -275,7 +275,6 @@ fun RenderThreadFeed(
val modifier =
Modifier
.drawReplyLevel(
note = item,
level = level,
color = MaterialTheme.colorScheme.placeholderText,
selected =
Expand Down Expand Up @@ -323,7 +322,6 @@ fun RenderThreadFeed(

// Creates a Zebra pattern where each bar is a reply level.
fun Modifier.drawReplyLevel(
note: Note,
level: State<Int>,
color: Color,
selected: Color,
Expand Down Expand Up @@ -485,14 +483,11 @@ 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(
Expand All @@ -513,11 +508,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) {
Expand Down Expand Up @@ -564,9 +559,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) {
Expand Down Expand Up @@ -675,9 +670,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),
Expand All @@ -686,7 +680,7 @@ private fun FullBleedNoteCompose(
}
}

ReactionsRow(baseNote, true, true, editState, accountViewModel, nav)
ReactionsRow(baseNote, showReactionDetail = true, addPadding = true, editState = editState, accountViewModel = accountViewModel, nav = nav)
}
}

Expand Down Expand Up @@ -938,14 +932,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,
)
}
}
Expand Down
2 changes: 2 additions & 0 deletions amethyst/src/main/res/values-hi-rIN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,8 @@
<string name="zap_forward_explainer">अवलम्बन करनेवाले ग्राहक ज्सापों को आगे भेजेंगे लै॰जाल पता को अथवा नीचे के उपयोगकर्ता परिचय को तथा आपके तक नहीं</string>
<string name="geohash_title">स्थान अनावृत करें ऐसे </string>
<string name="geohash_explainer">आपका भूगोलिक स्थान विभेदक जोडता है पत्र में। जनता जान जाएगी कि आप वर्तमान स्थान से ५ कि॰मे॰ (३ मी॰) की दूरी के अन्दर हैं</string>
<string name="loading_location">स्थान प्राप्त किया जा रहा है</string>
<string name="lack_location_permissions">स्थान प्राप्त करने की अनुमति नहीं</string>
<string name="add_sensitive_content_explainer">आपके विषयवस्तु दिखाने से पूर्व संवेदनशील विषयवस्तु चेतावनी जोडता है। यह आदर्श है किसी कार्यालय अनुचित विषयवस्तु के लिए अथवा जो कुछ लोगों के लिए आपत्तिजनक अथवा व्याकुल करनेवाला लग सकता है</string>
<string name="new_feature_nip17_might_not_be_available_title">नयी सुविधा</string>
<string name="new_feature_nip17_might_not_be_available_description">इस कार्यशैली सक्षम करने के लिए अमेथिस्ट के द्वारा निप॰-१७ संदेश (उपहारकोषयुक्त, आच्छादित सीधा तथा झुण्ड संदेश) भेजना पडेगा। यह निप॰-१७ नया है तथा अनेक ग्राहक इसे कार्यान्वित किया नहीं अब तक। सुनिश्चित करें कि प्राप्तकर्ता एक अनुकूल ग्राहक का प्रयोग कर रहे हैं।</string>
Expand Down
2 changes: 2 additions & 0 deletions amethyst/src/main/res/values-hu/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,8 @@
<string name="zap_forward_explainer">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</string>
<string name="geohash_title">A Hely megjelenítése mint </string>
<string name="geohash_explainer">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</string>
<string name="loading_location">Hely betöltése</string>
<string name="lack_location_permissions">Helymeghatározás nincs engedélyezve</string>
<string name="add_sensitive_content_explainer">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</string>
<string name="new_feature_nip17_might_not_be_available_title">Új funkció</string>
<string name="new_feature_nip17_might_not_be_available_description">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.</string>
Expand Down
2 changes: 2 additions & 0 deletions amethyst/src/main/res/values-nl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,8 @@
<string name="zap_forward_explainer">Ondersteunende clients sturen zaps door naar het onderstaande LN-adres of gebruikersprofiel in plaats van naar het jouwe</string>
<string name="geohash_title">Locatie weergeven als</string>
<string name="geohash_explainer">Voegt een Geohash van je locatie toe aan het bericht. Het publiek weet dat je binnen 5 km (3mi) van de huidige locatie bent.</string>
<string name="loading_location">Locatie laden</string>
<string name="lack_location_permissions">Geen locatiemachtigingen</string>
<string name="add_sensitive_content_explainer">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.</string>
<string name="new_feature_nip17_might_not_be_available_title">Nieuwe functie</string>
<string name="new_feature_nip17_might_not_be_available_description">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.</string>
Expand Down
2 changes: 2 additions & 0 deletions amethyst/src/main/res/values-pl-rPL/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,8 @@
<string name="zap_forward_explainer">Wspierający klient podzieli i przekaże zapy na LNAdres lub profil użytkownika poniżej zamiast Ciebie</string>
<string name="geohash_title">Wyświetl lokalizację jako </string>
<string name="geohash_explainer">Dodaje Geohash twojej lokalizacji do wpisu. Użytkownicy będą wiedzieli, że jesteś mniej niż 5 km od bieżącej lokalizacji</string>
<string name="loading_location">Pobieranie lokalizacji</string>
<string name="lack_location_permissions">Brak dostępu do lokalizacji</string>
<string name="add_sensitive_content_explainer">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</string>
<string name="new_feature_nip17_might_not_be_available_title">Nowa Funkcjonalność</string>
<string name="new_feature_nip17_might_not_be_available_description">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.</string>
Expand Down

0 comments on commit 04d6da2

Please sign in to comment.