Displays Approval Notes in the notifications
This commit is contained in:
@@ -849,7 +849,7 @@ object LocalCache {
|
|||||||
|
|
||||||
note.loadEvent(event, author, replyTo)
|
note.loadEvent(event, author, replyTo)
|
||||||
|
|
||||||
Log.d("CM", "New Chat Note (${note.author?.toBestDisplayName()} ${note.event?.content()} ${formattedDateTime(event.createdAt)}")
|
// Log.d("CM", "New Chat Note (${note.author?.toBestDisplayName()} ${note.event?.content()} ${formattedDateTime(event.createdAt)}")
|
||||||
|
|
||||||
// Counts the replies
|
// Counts the replies
|
||||||
replyTo.forEach {
|
replyTo.forEach {
|
||||||
|
|||||||
@@ -20,13 +20,21 @@ class CommunityFeedFilter(val note: AddressableNote, val account: Account) : Add
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun innerApplyFilter(collection: Collection<Note>): Set<Note> {
|
private fun innerApplyFilter(collection: Collection<Note>): Set<Note> {
|
||||||
return collection
|
val myUnapprovedPosts = collection.asSequence()
|
||||||
|
.filter { it.author?.pubkeyHex == account.userProfile().pubkeyHex } // made by the logged in user
|
||||||
|
.filter { it.event?.isTaggedAddressableNote(note.idHex) == true } // for this community
|
||||||
|
.filter { it.isNewThread() } // check if it is a new thread
|
||||||
|
.toSet()
|
||||||
|
|
||||||
|
val approvedPosts = collection
|
||||||
.asSequence()
|
.asSequence()
|
||||||
.filter { it.event is CommunityPostApprovalEvent } // Only Approvals
|
.filter { it.event is CommunityPostApprovalEvent } // Only Approvals
|
||||||
.filter { it.event?.isTaggedAddressableNote(note.idHex) == true } // Of the given community
|
.filter { it.event?.isTaggedAddressableNote(note.idHex) == true } // Of the given community
|
||||||
.mapNotNull { it.replyTo }.flatten() // get approved posts
|
.mapNotNull { it.replyTo }.flatten() // get approved posts
|
||||||
.filter { it.isNewThread() } // check if it is a new thread
|
.filter { it.isNewThread() } // check if it is a new thread
|
||||||
.toSet()
|
.toSet()
|
||||||
|
|
||||||
|
return myUnapprovedPosts + approvedPosts
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun sort(collection: Set<Note>): List<Note> {
|
override fun sort(collection: Set<Note>): List<Note> {
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ import coil.compose.AsyncImage
|
|||||||
import coil.compose.AsyncImagePainter
|
import coil.compose.AsyncImagePainter
|
||||||
import coil.request.SuccessResult
|
import coil.request.SuccessResult
|
||||||
import com.vitorpamplona.amethyst.R
|
import com.vitorpamplona.amethyst.R
|
||||||
|
import com.vitorpamplona.amethyst.model.AddressableNote
|
||||||
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
|
||||||
@@ -104,6 +105,7 @@ import com.vitorpamplona.amethyst.service.model.ChannelCreateEvent
|
|||||||
import com.vitorpamplona.amethyst.service.model.ChannelMessageEvent
|
import com.vitorpamplona.amethyst.service.model.ChannelMessageEvent
|
||||||
import com.vitorpamplona.amethyst.service.model.ChannelMetadataEvent
|
import com.vitorpamplona.amethyst.service.model.ChannelMetadataEvent
|
||||||
import com.vitorpamplona.amethyst.service.model.CommunityDefinitionEvent
|
import com.vitorpamplona.amethyst.service.model.CommunityDefinitionEvent
|
||||||
|
import com.vitorpamplona.amethyst.service.model.CommunityPostApprovalEvent
|
||||||
import com.vitorpamplona.amethyst.service.model.FileHeaderEvent
|
import com.vitorpamplona.amethyst.service.model.FileHeaderEvent
|
||||||
import com.vitorpamplona.amethyst.service.model.FileStorageHeaderEvent
|
import com.vitorpamplona.amethyst.service.model.FileStorageHeaderEvent
|
||||||
import com.vitorpamplona.amethyst.service.model.GenericRepostEvent
|
import com.vitorpamplona.amethyst.service.model.GenericRepostEvent
|
||||||
@@ -497,7 +499,8 @@ fun CommunityHeader(
|
|||||||
model = it,
|
model = it,
|
||||||
contentDescription = stringResource(R.string.profile_image),
|
contentDescription = stringResource(R.string.profile_image),
|
||||||
contentScale = ContentScale.Crop,
|
contentScale = ContentScale.Crop,
|
||||||
modifier = Modifier.padding(start = 10.dp)
|
modifier = Modifier
|
||||||
|
.padding(start = 10.dp)
|
||||||
.width(Size35dp)
|
.width(Size35dp)
|
||||||
.height(Size35dp)
|
.height(Size35dp)
|
||||||
.clip(shape = CircleShape)
|
.clip(shape = CircleShape)
|
||||||
@@ -708,7 +711,8 @@ fun InnerNoteWithReactions(
|
|||||||
|
|
||||||
Row(
|
Row(
|
||||||
modifier = remember {
|
modifier = remember {
|
||||||
Modifier.fillMaxWidth()
|
Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
.padding(
|
.padding(
|
||||||
start = if (!isBoostedNote) 12.dp else 0.dp,
|
start = if (!isBoostedNote) 12.dp else 0.dp,
|
||||||
end = if (!isBoostedNote) 12.dp else 0.dp,
|
end = if (!isBoostedNote) 12.dp else 0.dp,
|
||||||
@@ -914,6 +918,17 @@ private fun RenderNoteRow(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
is CommunityPostApprovalEvent -> {
|
||||||
|
RenderPostApproval(
|
||||||
|
baseNote,
|
||||||
|
makeItShort,
|
||||||
|
canPreview,
|
||||||
|
backgroundColor,
|
||||||
|
accountViewModel,
|
||||||
|
nav
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
RenderTextEvent(
|
RenderTextEvent(
|
||||||
baseNote,
|
baseNote,
|
||||||
@@ -1644,6 +1659,76 @@ fun RenderRepost(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun RenderPostApproval(
|
||||||
|
note: Note,
|
||||||
|
makeItShort: Boolean,
|
||||||
|
canPreview: Boolean,
|
||||||
|
backgroundColor: MutableState<Color>,
|
||||||
|
accountViewModel: AccountViewModel,
|
||||||
|
nav: (String) -> Unit
|
||||||
|
) {
|
||||||
|
if (note.replyTo.isNullOrEmpty()) return
|
||||||
|
|
||||||
|
val noteEvent = note.event as? CommunityPostApprovalEvent ?: return
|
||||||
|
|
||||||
|
Column(Modifier.fillMaxWidth()) {
|
||||||
|
noteEvent.communities().forEach {
|
||||||
|
LoadAddressableNote(it) {
|
||||||
|
it?.let {
|
||||||
|
NoteCompose(
|
||||||
|
it,
|
||||||
|
parentBackgroundColor = backgroundColor,
|
||||||
|
accountViewModel = accountViewModel,
|
||||||
|
nav = nav
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Text(
|
||||||
|
text = stringResource(id = R.string.community_approved_posts),
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
maxLines = 1,
|
||||||
|
overflow = TextOverflow.Ellipsis,
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(5.dp),
|
||||||
|
textAlign = TextAlign.Center
|
||||||
|
)
|
||||||
|
|
||||||
|
note.replyTo?.forEach {
|
||||||
|
NoteCompose(
|
||||||
|
it,
|
||||||
|
modifier = MaterialTheme.colors.replyModifier,
|
||||||
|
unPackReply = false,
|
||||||
|
makeItShort = true,
|
||||||
|
isQuotedNote = true,
|
||||||
|
parentBackgroundColor = backgroundColor,
|
||||||
|
accountViewModel = accountViewModel,
|
||||||
|
nav = nav
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun LoadAddressableNote(aTag: ATag, content: @Composable (AddressableNote?) -> Unit) {
|
||||||
|
var note by remember(aTag) {
|
||||||
|
mutableStateOf<AddressableNote?>(LocalCache.getAddressableNoteIfExists(aTag.toTag()))
|
||||||
|
}
|
||||||
|
|
||||||
|
if (note == null) {
|
||||||
|
LaunchedEffect(key1 = aTag) {
|
||||||
|
launch(Dispatchers.IO) {
|
||||||
|
note = LocalCache.getOrCreateAddressableNote(aTag)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
content(note)
|
||||||
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun RenderPinListEvent(
|
private fun RenderPinListEvent(
|
||||||
baseNote: Note,
|
baseNote: Note,
|
||||||
|
|||||||
@@ -476,4 +476,5 @@
|
|||||||
<string name="discover_live">Live</string>
|
<string name="discover_live">Live</string>
|
||||||
<string name="discover_community">Communities</string>
|
<string name="discover_community">Communities</string>
|
||||||
<string name="discover_chat">Chat Groups</string>
|
<string name="discover_chat">Chat Groups</string>
|
||||||
|
<string name="community_approved_posts">Approved Posts</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user