|
|
@ -78,7 +78,7 @@ class MessagesNode @AssistedInject constructor( |
|
|
|
private val timelineController: TimelineController, |
|
|
|
private val timelineController: TimelineController, |
|
|
|
) : Node(buildContext, plugins = plugins), MessagesNavigator { |
|
|
|
) : Node(buildContext, plugins = plugins), MessagesNavigator { |
|
|
|
private val presenter = presenterFactory.create(this) |
|
|
|
private val presenter = presenterFactory.create(this) |
|
|
|
private val callback = plugins<Callback>().firstOrNull() |
|
|
|
private val callbacks = plugins<Callback>() |
|
|
|
|
|
|
|
|
|
|
|
data class Inputs(val focusedEventId: EventId?) : NodeInputs |
|
|
|
data class Inputs(val focusedEventId: EventId?) : NodeInputs |
|
|
|
|
|
|
|
|
|
|
@ -113,19 +113,25 @@ class MessagesNode @AssistedInject constructor( |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun onRoomDetailsClick() { |
|
|
|
private fun onRoomDetailsClick() { |
|
|
|
callback?.onRoomDetailsClick() |
|
|
|
callbacks.forEach { it.onRoomDetailsClick() } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun onEventClick(event: TimelineItem.Event): Boolean { |
|
|
|
private fun onEventClick(event: TimelineItem.Event): Boolean { |
|
|
|
return callback?.onEventClick(event).orFalse() |
|
|
|
// Note: cannot use `callbacks.all { it.onEventClick(event) }` because: |
|
|
|
|
|
|
|
// - if callbacks is empty, it will return true and we want to return false. |
|
|
|
|
|
|
|
// - if a callback returns false, the other callback will not be invoked. |
|
|
|
|
|
|
|
return callbacks.takeIf { it.isNotEmpty() } |
|
|
|
|
|
|
|
?.map { it.onEventClick(event) } |
|
|
|
|
|
|
|
?.all { it } |
|
|
|
|
|
|
|
.orFalse() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun onPreviewAttachments(attachments: ImmutableList<Attachment>) { |
|
|
|
private fun onPreviewAttachments(attachments: ImmutableList<Attachment>) { |
|
|
|
callback?.onPreviewAttachments(attachments) |
|
|
|
callbacks.forEach { it.onPreviewAttachments(attachments) } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun onUserDataClick(userId: UserId) { |
|
|
|
private fun onUserDataClick(userId: UserId) { |
|
|
|
callback?.onUserDataClick(userId) |
|
|
|
callbacks.forEach { it.onUserDataClick(userId) } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun onLinkClick( |
|
|
|
private fun onLinkClick( |
|
|
@ -137,7 +143,7 @@ class MessagesNode @AssistedInject constructor( |
|
|
|
is PermalinkData.UserLink -> { |
|
|
|
is PermalinkData.UserLink -> { |
|
|
|
// Open the room member profile, it will fallback to |
|
|
|
// Open the room member profile, it will fallback to |
|
|
|
// the user profile if the user is not in the room |
|
|
|
// the user profile if the user is not in the room |
|
|
|
callback?.onUserDataClick(permalink.userId) |
|
|
|
callbacks.forEach { it.onUserDataClick(permalink.userId) } |
|
|
|
} |
|
|
|
} |
|
|
|
is PermalinkData.RoomLink -> { |
|
|
|
is PermalinkData.RoomLink -> { |
|
|
|
handleRoomLinkClick(permalink, eventSink) |
|
|
|
handleRoomLinkClick(permalink, eventSink) |
|
|
@ -159,36 +165,36 @@ class MessagesNode @AssistedInject constructor( |
|
|
|
context.toast("Already viewing this room!") |
|
|
|
context.toast("Already viewing this room!") |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
callback?.onPermalinkClick(roomLink) |
|
|
|
callbacks.forEach { it.onPermalinkClick(roomLink) } |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun onShowEventDebugInfoClick(eventId: EventId?, debugInfo: TimelineItemDebugInfo) { |
|
|
|
override fun onShowEventDebugInfoClick(eventId: EventId?, debugInfo: TimelineItemDebugInfo) { |
|
|
|
callback?.onShowEventDebugInfoClick(eventId, debugInfo) |
|
|
|
callbacks.forEach { it.onShowEventDebugInfoClick(eventId, debugInfo) } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun onForwardEventClick(eventId: EventId) { |
|
|
|
override fun onForwardEventClick(eventId: EventId) { |
|
|
|
callback?.onForwardEventClick(eventId) |
|
|
|
callbacks.forEach { it.onForwardEventClick(eventId) } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun onReportContentClick(eventId: EventId, senderId: UserId) { |
|
|
|
override fun onReportContentClick(eventId: EventId, senderId: UserId) { |
|
|
|
callback?.onReportMessage(eventId, senderId) |
|
|
|
callbacks.forEach { it.onReportMessage(eventId, senderId) } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun onEditPollClick(eventId: EventId) { |
|
|
|
override fun onEditPollClick(eventId: EventId) { |
|
|
|
callback?.onEditPollClick(eventId) |
|
|
|
callbacks.forEach { it.onEditPollClick(eventId) } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun onSendLocationClick() { |
|
|
|
private fun onSendLocationClick() { |
|
|
|
callback?.onSendLocationClick() |
|
|
|
callbacks.forEach { it.onSendLocationClick() } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun onCreatePollClick() { |
|
|
|
private fun onCreatePollClick() { |
|
|
|
callback?.onCreatePollClick() |
|
|
|
callbacks.forEach { it.onCreatePollClick() } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun onJoinCallClick() { |
|
|
|
private fun onJoinCallClick() { |
|
|
|
callback?.onJoinCallClick(room.roomId) |
|
|
|
callbacks.forEach { it.onJoinCallClick(room.roomId) } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Composable |
|
|
|
@Composable |
|
|
|