Merge pull request #1179 from davotoula/1172-hide-drafts-from-other-accounts-on-device
Hide drafts from other accounts on device
This commit is contained in:
@@ -27,11 +27,12 @@ import com.vitorpamplona.amethyst.model.Note
|
|||||||
import com.vitorpamplona.amethyst.model.ThreadAssembler
|
import com.vitorpamplona.amethyst.model.ThreadAssembler
|
||||||
import com.vitorpamplona.amethyst.model.ThreadLevelCalculator
|
import com.vitorpamplona.amethyst.model.ThreadLevelCalculator
|
||||||
import com.vitorpamplona.quartz.utils.TimeUtils
|
import com.vitorpamplona.quartz.utils.TimeUtils
|
||||||
|
import kotlinx.collections.immutable.toImmutableSet
|
||||||
|
|
||||||
@Immutable
|
@Immutable
|
||||||
class ThreadFeedFilter(
|
class ThreadFeedFilter(
|
||||||
val account: Account,
|
val account: Account,
|
||||||
val noteId: String,
|
private val noteId: String,
|
||||||
) : FeedFilter<Note>() {
|
) : FeedFilter<Note>() {
|
||||||
override fun feedKey(): String = noteId
|
override fun feedKey(): String = noteId
|
||||||
|
|
||||||
@@ -40,7 +41,14 @@ class ThreadFeedFilter(
|
|||||||
val followingKeySet = account.liveKind3Follows.value.authors
|
val followingKeySet = account.liveKind3Follows.value.authors
|
||||||
val eventsToWatch = ThreadAssembler().findThreadFor(noteId) ?: return emptyList()
|
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()
|
val now = TimeUtils.now()
|
||||||
|
|
||||||
// Currently orders by date of each event, descending, at each level of the reply stack
|
// Currently orders by date of each event, descending, at each level of the reply stack
|
||||||
@@ -57,6 +65,6 @@ class ThreadFeedFilter(
|
|||||||
).signature
|
).signature
|
||||||
}
|
}
|
||||||
|
|
||||||
return eventsToWatch.allNotes.sortedWith(order)
|
return filteredThreadInfo.allNotes.sortedWith(order)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-27
@@ -242,9 +242,9 @@ fun RenderThreadFeed(
|
|||||||
// In that case, this screen will open with 0-1 items, and the scrollToItem below
|
// 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)
|
// 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
|
// 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
|
// 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
|
// This hack allows the list 1 second to fill up with more
|
||||||
// records before setting up the position on the feed.
|
// records before setting up the position on the feed.
|
||||||
@@ -274,7 +274,6 @@ fun RenderThreadFeed(
|
|||||||
val modifier =
|
val modifier =
|
||||||
Modifier
|
Modifier
|
||||||
.drawReplyLevel(
|
.drawReplyLevel(
|
||||||
note = item,
|
|
||||||
level = level,
|
level = level,
|
||||||
color = MaterialTheme.colorScheme.placeholderText,
|
color = MaterialTheme.colorScheme.placeholderText,
|
||||||
selected =
|
selected =
|
||||||
@@ -322,7 +321,6 @@ fun RenderThreadFeed(
|
|||||||
|
|
||||||
// Creates a Zebra pattern where each bar is a reply level.
|
// Creates a Zebra pattern where each bar is a reply level.
|
||||||
fun Modifier.drawReplyLevel(
|
fun Modifier.drawReplyLevel(
|
||||||
note: Note,
|
|
||||||
level: State<Int>,
|
level: State<Int>,
|
||||||
color: Color,
|
color: Color,
|
||||||
selected: Color,
|
selected: Color,
|
||||||
@@ -484,14 +482,11 @@ private fun FullBleedNoteCompose(
|
|||||||
|
|
||||||
Spacer(modifier = Modifier.height(10.dp))
|
Spacer(modifier = Modifier.height(10.dp))
|
||||||
|
|
||||||
if (noteEvent is BadgeDefinitionEvent) {
|
when (noteEvent) {
|
||||||
BadgeDisplay(baseNote = baseNote)
|
is BadgeDefinitionEvent -> BadgeDisplay(baseNote = baseNote)
|
||||||
} else if (noteEvent is LongTextNoteEvent) {
|
is LongTextNoteEvent -> RenderLongFormHeaderForThread(noteEvent)
|
||||||
RenderLongFormHeaderForThread(noteEvent)
|
is WikiNoteEvent -> RenderWikiHeaderForThread(noteEvent, accountViewModel, nav)
|
||||||
} else if (noteEvent is WikiNoteEvent) {
|
is ClassifiedsEvent -> RenderClassifiedsReaderForThread(noteEvent, baseNote, accountViewModel, nav)
|
||||||
RenderWikiHeaderForThread(noteEvent, accountViewModel, nav)
|
|
||||||
} else if (noteEvent is ClassifiedsEvent) {
|
|
||||||
RenderClassifiedsReaderForThread(noteEvent, baseNote, accountViewModel, nav)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
@@ -512,11 +507,11 @@ private fun FullBleedNoteCompose(
|
|||||||
nav = nav,
|
nav = nav,
|
||||||
)
|
)
|
||||||
} else if (noteEvent is VideoEvent) {
|
} 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) {
|
} else if (noteEvent is FileHeaderEvent) {
|
||||||
FileHeaderDisplay(baseNote, true, false, accountViewModel)
|
FileHeaderDisplay(baseNote, roundedCorner = true, isFiniteHeight = false, accountViewModel = accountViewModel)
|
||||||
} else if (noteEvent is FileStorageHeaderEvent) {
|
} else if (noteEvent is FileStorageHeaderEvent) {
|
||||||
FileStorageHeaderDisplay(baseNote, true, false, accountViewModel)
|
FileStorageHeaderDisplay(baseNote, roundedCorner = true, isFiniteHeight = false, accountViewModel = accountViewModel)
|
||||||
} else if (noteEvent is PeopleListEvent) {
|
} else if (noteEvent is PeopleListEvent) {
|
||||||
DisplayPeopleList(baseNote, backgroundColor, accountViewModel, nav)
|
DisplayPeopleList(baseNote, backgroundColor, accountViewModel, nav)
|
||||||
} else if (noteEvent is AudioTrackEvent) {
|
} else if (noteEvent is AudioTrackEvent) {
|
||||||
@@ -563,9 +558,9 @@ private fun FullBleedNoteCompose(
|
|||||||
} else if (noteEvent is GitRepositoryEvent) {
|
} else if (noteEvent is GitRepositoryEvent) {
|
||||||
RenderGitRepositoryEvent(baseNote, accountViewModel, nav)
|
RenderGitRepositoryEvent(baseNote, accountViewModel, nav)
|
||||||
} else if (noteEvent is GitPatchEvent) {
|
} 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) {
|
} 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) {
|
} else if (noteEvent is AppDefinitionEvent) {
|
||||||
RenderAppDefinition(baseNote, accountViewModel, nav)
|
RenderAppDefinition(baseNote, accountViewModel, nav)
|
||||||
} else if (noteEvent is DraftEvent) {
|
} else if (noteEvent is DraftEvent) {
|
||||||
@@ -662,9 +657,8 @@ private fun FullBleedNoteCompose(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val noteEvent = baseNote.event
|
val zapSplits = remember(noteEvent) { noteEvent.hasZapSplitSetup() }
|
||||||
val zapSplits = remember(noteEvent) { noteEvent?.hasZapSplitSetup() ?: false }
|
if (zapSplits) {
|
||||||
if (zapSplits && noteEvent != null) {
|
|
||||||
Spacer(modifier = DoubleVertSpacer)
|
Spacer(modifier = DoubleVertSpacer)
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier.padding(horizontal = 12.dp),
|
modifier = Modifier.padding(horizontal = 12.dp),
|
||||||
@@ -673,7 +667,7 @@ private fun FullBleedNoteCompose(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ReactionsRow(baseNote, true, true, editState, accountViewModel, nav)
|
ReactionsRow(baseNote, showReactionDetail = true, addPadding = true, editState = editState, accountViewModel = accountViewModel, nav = nav)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -925,14 +919,14 @@ private fun RenderWikiHeaderForThreadPreview() {
|
|||||||
RenderWikiHeaderForThread(noteEvent = event, accountViewModel = accountViewModel, nav)
|
RenderWikiHeaderForThread(noteEvent = event, accountViewModel = accountViewModel, nav)
|
||||||
RenderTextEvent(
|
RenderTextEvent(
|
||||||
baseNote!!,
|
baseNote!!,
|
||||||
false,
|
makeItShort = false,
|
||||||
true,
|
canPreview = true,
|
||||||
quotesLeft = 3,
|
quotesLeft = 3,
|
||||||
unPackReply = false,
|
unPackReply = false,
|
||||||
backgroundColor,
|
backgroundColor = backgroundColor,
|
||||||
editState,
|
editState = editState,
|
||||||
accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
nav,
|
nav = nav,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user