fix: show empty Marmot groups in Messages screen
Previously ChatroomListKnownFeedFilter dropped any group whose newestMessage was null, so groups the user just created and groups received via Welcome events without any activity yet never appeared in the Messages list. Emit a stable placeholder Note (carrying the chatroom as a gatherer) per empty group, route it through the existing Marmot row path, and invalidate dmKnown on MarmotGroupList.groupListChanges so newly added or promoted groups rebuild the feed.
This commit is contained in:
+21
@@ -59,6 +59,27 @@ class MarmotGroupChatroom(
|
||||
*/
|
||||
var ownerSentMessage: Boolean = false
|
||||
|
||||
// Synthetic note used by list views to represent the group when no
|
||||
// messages have been received yet. Lazily created and kept stable so
|
||||
// equality-based feed diffing treats it as the same row across refreshes.
|
||||
private var cachedPlaceholder: Note? = null
|
||||
|
||||
@Synchronized
|
||||
fun placeholderNote(): Note {
|
||||
val existing = cachedPlaceholder
|
||||
if (existing != null) return existing
|
||||
val created =
|
||||
Note(placeholderIdHex(nostrGroupId)).apply {
|
||||
addGatherer(this@MarmotGroupChatroom)
|
||||
}
|
||||
cachedPlaceholder = created
|
||||
return created
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun placeholderIdHex(nostrGroupId: HexKey): HexKey = "marmot-empty-$nostrGroupId"
|
||||
}
|
||||
|
||||
private var changesFlow: WeakReference<MutableSharedFlow<ListChange<Note>>> = WeakReference(null)
|
||||
|
||||
fun changesFlow(): MutableSharedFlow<ListChange<Note>> {
|
||||
|
||||
Reference in New Issue
Block a user