Add support for Direct Share targets. #6024
Conversation
406e340 to
8a74480
Compare
|
@mahibi Hey, I saw that your recent commit changed incoming message handling quite a bit. I wanted to double check what the best place is to react to a new incoming message? Right now I'm using OfflineFirstChatRepository.kt but I'm not sure that's the right place. Thanks! |
…ing the share sheet, it can now suggest Nextcloud Talk contacts. Signed-off-by: Jens Zalzala <jens@shakingearthdigital.com>
8a74480 to
ad9275b
Compare
|
Thanks @anakin78z |
mahibi
left a comment
There was a problem hiding this comment.
Great contribution, it works pretty good! 👍
You are right to question if OfflineFirstChatRepo is the correct place to call the DirectShareHelper.
It should not directly call it. I suggest to add another flow and then obesrve this in the ChatViewModel.
Lets add this flow in the OfflineFirstChatRepo:
override val incomingMessageFlow: Flow<Unit>
get() = _incomingMessageFlow
private val _incomingMessageFlow: MutableSharedFlow<Unit> = MutableSharedFlow()
Move the emitOnIncoming block into persistChatMessagesAndHandleSystemMessages:
suspend fun persistChatMessagesAndHandleSystemMessages(
chatMessages: List<ChatMessageJson>,
emitOnIncoming: Boolean = false
): List<ChatMessageEntity> {
handleSystemMessagesThatAffectDatabase(chatMessages)
val chatMessageEntities = chatMessages.map {
it.asEntity(currentUser.id!!)
}
chatDao.upsertChatMessagesAndDeleteTemp(internalConversationId, chatMessageEntities)
if (emitOnIncoming) {
val hasIncomingFromOther = chatMessages.any { msg ->
msg.systemMessageType == ChatMessage.SystemMessageType.DUMMY &&
msg.actorId != currentUser.userId
}
if (hasIncomingFromOther) {
_incomingMessageFlow.emit(Unit)
}
}
return chatMessageEntities
}
In
OfflineFirstChatRepository.updateMessagesData , just pass lookIntoFuture
and in
onSignalingChatMessageReceived , just pass true
for emitOnIncoming
In ChatViewModel, observe the flow like this:
private fun observeIncomingMessages() {
chatRepository.incomingMessageFlow
.onEach {
val (conversation, user) = conversationAndUserFlow.first()
val context = NextcloudTalkApplication.sharedApplication!!
val isOneToOne = conversation.type == ConversationEnums.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL
DirectShareHelper.reportIncomingMessage(
context,
user,
conversation.token,
conversation.displayName ?: conversation.token,
isOneToOne
)
}
.launchIn(viewModelScope)
}
What do you think?
|
Great, I can give that a try, but if you think it would be quicker for you to just do it (looks like you pretty much have 😆), feel free. |
…to ChatViewModel.kt Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
i pushed this.
|
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
Yep, totally fine.
Sounds great. that email is good.
If that's easier for you, sure. If you can set it up so that I can't accidentally push to master, that would be best (probably already set up that way). |
invited
sure, that's set up. You should get an invite next week |
|
Thanks again, great PR 👍 |
|
Hello there, We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! (If you believe you should not receive this message, you can add yourself to the blocklist.) |
When an app shares something using the share sheet, it can now suggest Nextcloud Talk contacts.
🖼️ Screenshots
This also adds shortcuts to the app on the launcher, accessible by long pressing the app icon.
Note that it may end up pushing the Open Notes shortcut off the list, depending on how many active conversations you have going.
TESTING
Whether or not shortcuts show up in the share sheet is at the whim of Android's prioritization, so you may not see them right away. To guarantee that you can see them, start a new emulator and sign into Nextcloud Talk there. Direct Share contacts should show on the share sheet right away.
🚧 TODO
🏁 Checklist
/backport to stable-xx.x