Moves all note states to leaf compositors
This commit is contained in:
@@ -83,7 +83,6 @@ import com.vitorpamplona.amethyst.model.Account
|
|||||||
import com.vitorpamplona.amethyst.model.Channel
|
import com.vitorpamplona.amethyst.model.Channel
|
||||||
import com.vitorpamplona.amethyst.model.LocalCache
|
import com.vitorpamplona.amethyst.model.LocalCache
|
||||||
import com.vitorpamplona.amethyst.model.Note
|
import com.vitorpamplona.amethyst.model.Note
|
||||||
import com.vitorpamplona.amethyst.model.NoteState
|
|
||||||
import com.vitorpamplona.amethyst.model.User
|
import com.vitorpamplona.amethyst.model.User
|
||||||
import com.vitorpamplona.amethyst.service.model.AudioTrackEvent
|
import com.vitorpamplona.amethyst.service.model.AudioTrackEvent
|
||||||
import com.vitorpamplona.amethyst.service.model.BadgeAwardEvent
|
import com.vitorpamplona.amethyst.service.model.BadgeAwardEvent
|
||||||
@@ -151,9 +150,9 @@ fun NoteCompose(
|
|||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: (String) -> Unit
|
nav: (String) -> Unit
|
||||||
) {
|
) {
|
||||||
|
println("AARender NoteCompose")
|
||||||
val accountState by accountViewModel.accountLiveData.observeAsState()
|
val accountState by accountViewModel.accountLiveData.observeAsState()
|
||||||
val account = remember(accountState) { accountState?.account } ?: return
|
val account = remember(accountState) { accountState?.account } ?: return
|
||||||
val loggedIn = remember(accountState) { accountState?.account?.userProfile() } ?: return
|
|
||||||
|
|
||||||
val noteState by baseNote.live().metadata.observeAsState()
|
val noteState by baseNote.live().metadata.observeAsState()
|
||||||
val note = remember(noteState) { noteState?.note } ?: return
|
val note = remember(noteState) { noteState?.note } ?: return
|
||||||
@@ -161,13 +160,11 @@ fun NoteCompose(
|
|||||||
val noteReportsState by baseNote.live().reports.observeAsState()
|
val noteReportsState by baseNote.live().reports.observeAsState()
|
||||||
val noteForReports = remember(noteReportsState) { noteReportsState?.note } ?: return
|
val noteForReports = remember(noteReportsState) { noteReportsState?.note } ?: return
|
||||||
|
|
||||||
val noteEvent = remember(noteState) { note.event }
|
|
||||||
val channelHex = remember(noteState) { note.channelHex() }
|
|
||||||
val isSensitive = remember(noteState) { note.event?.isSensitive() ?: false }
|
val isSensitive = remember(noteState) { note.event?.isSensitive() ?: false }
|
||||||
|
|
||||||
var popupExpanded by remember { mutableStateOf(false) }
|
if (note.event == null) {
|
||||||
|
var popupExpanded by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
if (noteEvent == null) {
|
|
||||||
BlankNote(
|
BlankNote(
|
||||||
remember {
|
remember {
|
||||||
modifier.combinedClickable(
|
modifier.combinedClickable(
|
||||||
@@ -178,13 +175,11 @@ fun NoteCompose(
|
|||||||
isBoostedNote
|
isBoostedNote
|
||||||
)
|
)
|
||||||
|
|
||||||
note.let {
|
NoteQuickActionMenu(note, popupExpanded, { popupExpanded = false }, accountViewModel)
|
||||||
NoteQuickActionMenu(it, popupExpanded, { popupExpanded = false }, accountViewModel)
|
|
||||||
}
|
|
||||||
} else if (account.isHidden(noteForReports.author!!) || (isSensitive && account.showSensitiveContent == false)) {
|
} else if (account.isHidden(noteForReports.author!!) || (isSensitive && account.showSensitiveContent == false)) {
|
||||||
// Does nothing
|
// Does nothing
|
||||||
} else {
|
} else {
|
||||||
var showHiddenNote by remember { mutableStateOf(false) }
|
var showReportedNote by remember { mutableStateOf(false) }
|
||||||
var isAcceptableAndCanPreview by remember { mutableStateOf(Pair(true, true)) }
|
var isAcceptableAndCanPreview by remember { mutableStateOf(Pair(true, true)) }
|
||||||
|
|
||||||
LaunchedEffect(key1 = noteReportsState, key2 = accountState) {
|
LaunchedEffect(key1 = noteReportsState, key2 = accountState) {
|
||||||
@@ -203,192 +198,236 @@ fun NoteCompose(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isAcceptableAndCanPreview.first && !showHiddenNote) {
|
if (!isAcceptableAndCanPreview.first && !showReportedNote) {
|
||||||
HiddenNote(
|
HiddenNote(
|
||||||
account.getRelevantReports(noteForReports),
|
account.getRelevantReports(noteForReports),
|
||||||
account.userProfile(),
|
account.userProfile(),
|
||||||
modifier,
|
modifier,
|
||||||
isBoostedNote,
|
isBoostedNote,
|
||||||
nav,
|
nav,
|
||||||
onClick = { showHiddenNote = true }
|
onClick = { showReportedNote = true }
|
||||||
)
|
)
|
||||||
} else if ((noteEvent is ChannelCreateEvent || noteEvent is ChannelMetadataEvent) && channelHex != null) {
|
|
||||||
ChannelHeader(channelHex = channelHex, account = account, nav = nav)
|
|
||||||
} else if (noteEvent is BadgeDefinitionEvent) {
|
|
||||||
BadgeDisplay(baseNote = note)
|
|
||||||
} else if (noteEvent is FileHeaderEvent) {
|
|
||||||
FileHeaderDisplay(note)
|
|
||||||
} else if (noteEvent is FileStorageHeaderEvent) {
|
|
||||||
FileStorageHeaderDisplay(note)
|
|
||||||
} else {
|
} else {
|
||||||
var isNew by remember { mutableStateOf<Boolean>(false) }
|
NormalNote(
|
||||||
|
baseNote,
|
||||||
|
routeForLastRead,
|
||||||
|
modifier,
|
||||||
|
isBoostedNote,
|
||||||
|
isQuotedNote,
|
||||||
|
unPackReply,
|
||||||
|
makeItShort,
|
||||||
|
addMarginTop,
|
||||||
|
isAcceptableAndCanPreview.second,
|
||||||
|
parentBackgroundColor,
|
||||||
|
accountViewModel,
|
||||||
|
nav
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val scope = rememberCoroutineScope()
|
@OptIn(ExperimentalFoundationApi::class)
|
||||||
|
@Composable
|
||||||
|
fun NormalNote(
|
||||||
|
baseNote: Note,
|
||||||
|
routeForLastRead: String? = null,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
isBoostedNote: Boolean = false,
|
||||||
|
isQuotedNote: Boolean = false,
|
||||||
|
unPackReply: Boolean = true,
|
||||||
|
makeItShort: Boolean = false,
|
||||||
|
addMarginTop: Boolean = true,
|
||||||
|
canPreview: Boolean = true,
|
||||||
|
parentBackgroundColor: Color? = null,
|
||||||
|
accountViewModel: AccountViewModel,
|
||||||
|
nav: (String) -> Unit
|
||||||
|
) {
|
||||||
|
println("AARender NormalNote")
|
||||||
|
val accountState by accountViewModel.accountLiveData.observeAsState()
|
||||||
|
val account = remember(accountState) { accountState?.account } ?: return
|
||||||
|
val loggedIn = remember(accountState) { accountState?.account?.userProfile() } ?: return
|
||||||
|
|
||||||
LaunchedEffect(key1 = routeForLastRead) {
|
val noteEvent = remember { baseNote.event }
|
||||||
scope.launch(Dispatchers.IO) {
|
val channelHex = remember { baseNote.channelHex() }
|
||||||
routeForLastRead?.let {
|
|
||||||
val lastTime = NotificationCache.load(it)
|
|
||||||
|
|
||||||
val createdAt = note.createdAt()
|
var popupExpanded by remember { mutableStateOf(false) }
|
||||||
if (createdAt != null) {
|
|
||||||
NotificationCache.markAsRead(it, createdAt)
|
|
||||||
|
|
||||||
val newIsNew = createdAt > lastTime
|
if ((noteEvent is ChannelCreateEvent || noteEvent is ChannelMetadataEvent) && channelHex != null) {
|
||||||
if (newIsNew != isNew) {
|
ChannelHeader(channelHex = channelHex, account = account, nav = nav)
|
||||||
isNew = newIsNew
|
} else if (noteEvent is BadgeDefinitionEvent) {
|
||||||
}
|
BadgeDisplay(baseNote = baseNote)
|
||||||
|
} else if (noteEvent is FileHeaderEvent) {
|
||||||
|
FileHeaderDisplay(baseNote)
|
||||||
|
} else if (noteEvent is FileStorageHeaderEvent) {
|
||||||
|
FileStorageHeaderDisplay(baseNote)
|
||||||
|
} else {
|
||||||
|
var isNew by remember { mutableStateOf<Boolean>(false) }
|
||||||
|
|
||||||
|
val scope = rememberCoroutineScope()
|
||||||
|
|
||||||
|
LaunchedEffect(key1 = routeForLastRead) {
|
||||||
|
scope.launch(Dispatchers.IO) {
|
||||||
|
routeForLastRead?.let {
|
||||||
|
val lastTime = NotificationCache.load(it)
|
||||||
|
|
||||||
|
val createdAt = baseNote.createdAt()
|
||||||
|
if (createdAt != null) {
|
||||||
|
NotificationCache.markAsRead(it, createdAt)
|
||||||
|
|
||||||
|
val newIsNew = createdAt > lastTime
|
||||||
|
if (newIsNew != isNew) {
|
||||||
|
isNew = newIsNew
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val primaryColor = MaterialTheme.colors.primary.copy(0.12f)
|
val primaryColor = MaterialTheme.colors.primary.copy(0.12f)
|
||||||
val defaultBackgroundColor = MaterialTheme.colors.background
|
val defaultBackgroundColor = MaterialTheme.colors.background
|
||||||
|
|
||||||
val backgroundColor = remember(isNew, parentBackgroundColor) {
|
val backgroundColor = remember(isNew, parentBackgroundColor) {
|
||||||
if (isNew) {
|
if (isNew) {
|
||||||
if (parentBackgroundColor != null) {
|
if (parentBackgroundColor != null) {
|
||||||
primaryColor.compositeOver(parentBackgroundColor)
|
primaryColor.compositeOver(parentBackgroundColor)
|
||||||
} else {
|
|
||||||
primaryColor.compositeOver(defaultBackgroundColor)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
parentBackgroundColor ?: defaultBackgroundColor
|
primaryColor.compositeOver(defaultBackgroundColor)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
parentBackgroundColor ?: defaultBackgroundColor
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val columnModifier = remember(backgroundColor) {
|
val columnModifier = remember(backgroundColor) {
|
||||||
modifier
|
modifier
|
||||||
.combinedClickable(
|
.combinedClickable(
|
||||||
onClick = {
|
onClick = {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
routeFor(note, loggedIn)?.let {
|
routeFor(baseNote, loggedIn)?.let {
|
||||||
nav(it)
|
nav(it)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
onLongClick = { popupExpanded = true }
|
},
|
||||||
)
|
onLongClick = { popupExpanded = true }
|
||||||
.background(backgroundColor)
|
)
|
||||||
}
|
.background(backgroundColor)
|
||||||
|
}
|
||||||
|
|
||||||
Column(modifier = columnModifier) {
|
Column(modifier = columnModifier) {
|
||||||
Row(
|
Row(
|
||||||
|
modifier = remember {
|
||||||
|
Modifier
|
||||||
|
.padding(
|
||||||
|
start = if (!isBoostedNote) 12.dp else 0.dp,
|
||||||
|
end = if (!isBoostedNote) 12.dp else 0.dp,
|
||||||
|
top = if (addMarginTop && !isBoostedNote) 10.dp else 0.dp
|
||||||
|
)
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
if (!isBoostedNote && !isQuotedNote) {
|
||||||
|
DrawAuthorImages(baseNote, loggedIn, nav)
|
||||||
|
}
|
||||||
|
|
||||||
|
Column(
|
||||||
modifier = remember {
|
modifier = remember {
|
||||||
Modifier
|
Modifier
|
||||||
.padding(
|
.padding(start = if (!isBoostedNote && !isQuotedNote) 10.dp else 0.dp)
|
||||||
start = if (!isBoostedNote) 12.dp else 0.dp,
|
|
||||||
end = if (!isBoostedNote) 12.dp else 0.dp,
|
|
||||||
top = if (addMarginTop && !isBoostedNote) 10.dp else 0.dp
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
if (!isBoostedNote && !isQuotedNote) {
|
FirstUserInfoRow(
|
||||||
DrawAuthorImages(baseNote, loggedIn, nav)
|
baseNote = baseNote,
|
||||||
|
showAuthorPicture = isQuotedNote,
|
||||||
|
account = account,
|
||||||
|
accountViewModel = accountViewModel,
|
||||||
|
nav = nav
|
||||||
|
)
|
||||||
|
|
||||||
|
if (noteEvent !is RepostEvent && !makeItShort && !isQuotedNote) {
|
||||||
|
SecondUserInfoRow(
|
||||||
|
baseNote,
|
||||||
|
account,
|
||||||
|
nav
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
Column(
|
Spacer(modifier = Modifier.height(2.dp))
|
||||||
modifier = remember {
|
|
||||||
Modifier
|
if (!makeItShort) {
|
||||||
.padding(start = if (!isBoostedNote && !isQuotedNote) 10.dp else 0.dp)
|
ReplyRow(
|
||||||
}
|
baseNote,
|
||||||
) {
|
unPackReply,
|
||||||
FirstUserInfoRow(
|
backgroundColor,
|
||||||
baseNote = baseNote,
|
account,
|
||||||
showAuthorPicture = isQuotedNote,
|
accountViewModel,
|
||||||
account = account,
|
nav
|
||||||
accountViewModel = accountViewModel,
|
|
||||||
nav = nav
|
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
if (noteEvent !is RepostEvent && !makeItShort && !isQuotedNote) {
|
when (noteEvent) {
|
||||||
SecondUserInfoRow(
|
is ReactionEvent -> {
|
||||||
note,
|
RenderReaction(baseNote, backgroundColor, accountViewModel, nav)
|
||||||
account,
|
|
||||||
nav
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(2.dp))
|
is RepostEvent -> {
|
||||||
|
RenderRepost(baseNote, backgroundColor, accountViewModel, nav)
|
||||||
|
}
|
||||||
|
|
||||||
if (!makeItShort) {
|
is ReportEvent -> {
|
||||||
ReplyRow(
|
RenderReport(baseNote)
|
||||||
note,
|
}
|
||||||
unPackReply,
|
|
||||||
|
is LongTextNoteEvent -> {
|
||||||
|
RenderLongFormContent(baseNote, loggedIn, accountViewModel, nav)
|
||||||
|
}
|
||||||
|
|
||||||
|
is BadgeAwardEvent -> {
|
||||||
|
RenderBadgeAward(baseNote, backgroundColor, accountViewModel, nav)
|
||||||
|
}
|
||||||
|
|
||||||
|
is PeopleListEvent -> {
|
||||||
|
RenderPeopleList(baseNote, backgroundColor, accountViewModel, nav)
|
||||||
|
}
|
||||||
|
|
||||||
|
is AudioTrackEvent -> {
|
||||||
|
RenderAudioTrack(baseNote, loggedIn, accountViewModel, nav)
|
||||||
|
}
|
||||||
|
|
||||||
|
is PinListEvent -> {
|
||||||
|
RenderPinListEvent(baseNote, backgroundColor, accountViewModel, nav)
|
||||||
|
}
|
||||||
|
|
||||||
|
is PrivateDmEvent -> {
|
||||||
|
RenderPrivateMessage(baseNote, makeItShort, canPreview, backgroundColor, accountViewModel, nav)
|
||||||
|
}
|
||||||
|
|
||||||
|
is HighlightEvent -> {
|
||||||
|
RenderHighlight(baseNote, makeItShort, canPreview, backgroundColor, accountViewModel, nav)
|
||||||
|
}
|
||||||
|
|
||||||
|
is PollNoteEvent -> {
|
||||||
|
RenderPoll(
|
||||||
|
baseNote,
|
||||||
|
makeItShort,
|
||||||
|
canPreview,
|
||||||
backgroundColor,
|
backgroundColor,
|
||||||
account,
|
|
||||||
accountViewModel,
|
accountViewModel,
|
||||||
nav
|
nav
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
when (noteEvent) {
|
else -> {
|
||||||
is ReactionEvent -> {
|
RenderTextEvent(
|
||||||
RenderReaction(note, backgroundColor, accountViewModel, nav)
|
baseNote,
|
||||||
}
|
makeItShort,
|
||||||
|
canPreview,
|
||||||
is RepostEvent -> {
|
backgroundColor,
|
||||||
RenderRepost(note, backgroundColor, accountViewModel, nav)
|
accountViewModel,
|
||||||
}
|
nav
|
||||||
|
)
|
||||||
is ReportEvent -> {
|
|
||||||
RenderReport(note)
|
|
||||||
}
|
|
||||||
|
|
||||||
is LongTextNoteEvent -> {
|
|
||||||
RenderLongFormContent(note, loggedIn, accountViewModel, nav)
|
|
||||||
}
|
|
||||||
|
|
||||||
is BadgeAwardEvent -> {
|
|
||||||
RenderBadgeAward(note, backgroundColor, accountViewModel, nav)
|
|
||||||
}
|
|
||||||
|
|
||||||
is PeopleListEvent -> {
|
|
||||||
RenderPeopleList(noteState, backgroundColor, accountViewModel, nav)
|
|
||||||
}
|
|
||||||
|
|
||||||
is AudioTrackEvent -> {
|
|
||||||
RenderAudioTrack(note, loggedIn, accountViewModel, nav)
|
|
||||||
}
|
|
||||||
|
|
||||||
is PinListEvent -> {
|
|
||||||
RenderPinListEvent(noteState, backgroundColor, accountViewModel, nav)
|
|
||||||
}
|
|
||||||
|
|
||||||
is PrivateDmEvent -> {
|
|
||||||
RenderPrivateMessage(note, makeItShort, isAcceptableAndCanPreview.second, backgroundColor, accountViewModel, nav)
|
|
||||||
}
|
|
||||||
|
|
||||||
is HighlightEvent -> {
|
|
||||||
RenderHighlight(note, makeItShort, isAcceptableAndCanPreview.second, backgroundColor, accountViewModel, nav)
|
|
||||||
}
|
|
||||||
|
|
||||||
is PollNoteEvent -> {
|
|
||||||
RenderPoll(
|
|
||||||
note,
|
|
||||||
makeItShort,
|
|
||||||
isAcceptableAndCanPreview.second,
|
|
||||||
backgroundColor,
|
|
||||||
accountViewModel,
|
|
||||||
nav
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
else -> {
|
|
||||||
RenderTextEvent(
|
|
||||||
note,
|
|
||||||
makeItShort,
|
|
||||||
isAcceptableAndCanPreview.second,
|
|
||||||
backgroundColor,
|
|
||||||
accountViewModel,
|
|
||||||
nav
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NoteQuickActionMenu(note, popupExpanded, { popupExpanded = false }, accountViewModel)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NoteQuickActionMenu(baseNote, popupExpanded, { popupExpanded = false }, accountViewModel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -648,16 +687,14 @@ private fun RenderPrivateMessage(
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun RenderPeopleList(
|
fun RenderPeopleList(
|
||||||
noteState: NoteState?,
|
baseNote: Note,
|
||||||
backgroundColor: Color,
|
backgroundColor: Color,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: (String) -> Unit
|
nav: (String) -> Unit
|
||||||
) {
|
) {
|
||||||
DisplayPeopleList(noteState, backgroundColor, accountViewModel, nav)
|
DisplayPeopleList(baseNote, backgroundColor, accountViewModel, nav)
|
||||||
|
|
||||||
noteState?.note?.let {
|
ReactionsRow(baseNote, accountViewModel, nav)
|
||||||
ReactionsRow(it, accountViewModel, nav)
|
|
||||||
}
|
|
||||||
|
|
||||||
Divider(
|
Divider(
|
||||||
modifier = Modifier.padding(top = 10.dp),
|
modifier = Modifier.padding(top = 10.dp),
|
||||||
@@ -667,13 +704,12 @@ fun RenderPeopleList(
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun DisplayPeopleList(
|
fun DisplayPeopleList(
|
||||||
noteState: NoteState?,
|
baseNote: Note,
|
||||||
backgroundColor: Color,
|
backgroundColor: Color,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: (String) -> Unit
|
nav: (String) -> Unit
|
||||||
) {
|
) {
|
||||||
val note = remember(noteState) { noteState?.note } ?: return
|
val noteEvent = baseNote.event as? PeopleListEvent ?: return
|
||||||
val noteEvent = note.event as? PeopleListEvent ?: return
|
|
||||||
|
|
||||||
var members by remember { mutableStateOf<List<User>>(listOf()) }
|
var members by remember { mutableStateOf<List<User>>(listOf()) }
|
||||||
|
|
||||||
@@ -699,7 +735,7 @@ fun DisplayPeopleList(
|
|||||||
textAlign = TextAlign.Center
|
textAlign = TextAlign.Center
|
||||||
)
|
)
|
||||||
|
|
||||||
LaunchedEffect(key1 = noteState) {
|
LaunchedEffect(Unit) {
|
||||||
withContext(Dispatchers.IO) {
|
withContext(Dispatchers.IO) {
|
||||||
members = noteEvent.bookmarkedPeople().mapNotNull { hex ->
|
members = noteEvent.bookmarkedPeople().mapNotNull { hex ->
|
||||||
LocalCache.checkGetOrCreateUser(hex)
|
LocalCache.checkGetOrCreateUser(hex)
|
||||||
@@ -876,16 +912,16 @@ private fun RenderRepost(
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun RenderPinListEvent(
|
private fun RenderPinListEvent(
|
||||||
noteState: NoteState?,
|
baseNote: Note,
|
||||||
backgroundColor: Color,
|
backgroundColor: Color,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: (String) -> Unit
|
nav: (String) -> Unit
|
||||||
) {
|
) {
|
||||||
val noteEvent = noteState?.note?.event as? PinListEvent ?: return
|
val noteEvent = baseNote.event as? PinListEvent ?: return
|
||||||
|
|
||||||
PinListHeader(noteState, backgroundColor, accountViewModel, nav)
|
PinListHeader(baseNote, backgroundColor, accountViewModel, nav)
|
||||||
|
|
||||||
ReactionsRow(noteState?.note, accountViewModel, nav)
|
ReactionsRow(baseNote, accountViewModel, nav)
|
||||||
|
|
||||||
Divider(
|
Divider(
|
||||||
modifier = Modifier.padding(top = 10.dp),
|
modifier = Modifier.padding(top = 10.dp),
|
||||||
@@ -895,15 +931,14 @@ private fun RenderPinListEvent(
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun PinListHeader(
|
fun PinListHeader(
|
||||||
noteState: NoteState?,
|
baseNote: Note,
|
||||||
backgroundColor: Color,
|
backgroundColor: Color,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: (String) -> Unit
|
nav: (String) -> Unit
|
||||||
) {
|
) {
|
||||||
val note = remember(noteState) { noteState?.note } ?: return
|
val noteEvent = baseNote.event as? PinListEvent ?: return
|
||||||
val noteEvent = note.event as? PinListEvent ?: return
|
|
||||||
|
|
||||||
var pins by remember { mutableStateOf<List<String>>(noteEvent.pins()) }
|
var pins by remember { mutableStateOf(noteEvent.pins()) }
|
||||||
|
|
||||||
var expanded by remember {
|
var expanded by remember {
|
||||||
mutableStateOf(false)
|
mutableStateOf(false)
|
||||||
|
|||||||
@@ -353,11 +353,11 @@ fun NoteMaster(
|
|||||||
) {
|
) {
|
||||||
Column() {
|
Column() {
|
||||||
if (noteEvent is PeopleListEvent) {
|
if (noteEvent is PeopleListEvent) {
|
||||||
DisplayPeopleList(noteState, MaterialTheme.colors.background, accountViewModel, nav)
|
DisplayPeopleList(baseNote, MaterialTheme.colors.background, accountViewModel, nav)
|
||||||
} else if (noteEvent is AudioTrackEvent) {
|
} else if (noteEvent is AudioTrackEvent) {
|
||||||
AudioTrackHeader(noteEvent, note, account.userProfile(), nav)
|
AudioTrackHeader(noteEvent, note, account.userProfile(), nav)
|
||||||
} else if (noteEvent is PinListEvent) {
|
} else if (noteEvent is PinListEvent) {
|
||||||
PinListHeader(noteState, MaterialTheme.colors.background, accountViewModel, nav)
|
PinListHeader(baseNote, MaterialTheme.colors.background, accountViewModel, nav)
|
||||||
} else if (noteEvent is HighlightEvent) {
|
} else if (noteEvent is HighlightEvent) {
|
||||||
DisplayHighlight(
|
DisplayHighlight(
|
||||||
noteEvent.quote(),
|
noteEvent.quote(),
|
||||||
|
|||||||
Reference in New Issue
Block a user