mirror of
https://github.com/nextcloud/talk-android
synced 2025-03-06 14:27:24 +00:00
add ability to delete reactions
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
4e727924c2
commit
aa5046cf27
@ -112,7 +112,7 @@ class MessageActionsDialog(
|
||||
dialogMessageActionsBinding.emojiMore.clearFocus()
|
||||
dialogMessageActionsBinding.messageActions.visibility = View.VISIBLE
|
||||
|
||||
val imm: InputMethodManager = context?.getSystemService(Context.INPUT_METHOD_SERVICE) as
|
||||
val imm: InputMethodManager = context.getSystemService(Context.INPUT_METHOD_SERVICE) as
|
||||
InputMethodManager
|
||||
imm.hideSoftInputFromWindow(dialogMessageActionsBinding.emojiMore.windowToken, 0)
|
||||
}
|
||||
@ -257,7 +257,7 @@ class MessageActionsDialog(
|
||||
}
|
||||
|
||||
override fun onError(e: Throwable) {
|
||||
Log.e(TAG, "error while sending emoji")
|
||||
Log.e(TAG, "error while sending reaction")
|
||||
}
|
||||
|
||||
override fun onComplete() {
|
||||
|
@ -45,6 +45,7 @@ import com.nextcloud.talk.databinding.DialogMessageReactionsBinding
|
||||
import com.nextcloud.talk.models.database.UserEntity
|
||||
import com.nextcloud.talk.models.json.chat.ChatMessage
|
||||
import com.nextcloud.talk.models.json.conversations.Conversation
|
||||
import com.nextcloud.talk.models.json.generic.GenericOverall
|
||||
import com.nextcloud.talk.models.json.reactions.ReactionsOverall
|
||||
import com.nextcloud.talk.utils.ApiUtils
|
||||
import com.nextcloud.talk.utils.DisplayUtils
|
||||
@ -56,11 +57,11 @@ import io.reactivex.schedulers.Schedulers
|
||||
|
||||
@AutoInjector(NextcloudTalkApplication::class)
|
||||
class ShowReactionsDialog(
|
||||
val activity: Activity,
|
||||
val currentConversation: Conversation?,
|
||||
val chatMessage: ChatMessage,
|
||||
val userEntity: UserEntity?,
|
||||
val ncApi: NcApi
|
||||
private val activity: Activity,
|
||||
private val currentConversation: Conversation?,
|
||||
private val chatMessage: ChatMessage,
|
||||
private val userEntity: UserEntity?,
|
||||
private val ncApi: NcApi
|
||||
) : BottomSheetDialog(activity), ReactionItemClickListener {
|
||||
|
||||
private lateinit var binding: DialogMessageReactionsBinding
|
||||
@ -162,12 +163,46 @@ class ShowReactionsDialog(
|
||||
|
||||
override fun onClick(reactionItem: ReactionItem) {
|
||||
Log.d(TAG, "onClick(reactionItem: ReactionItem): " + reactionItem.reaction)
|
||||
// TODO implement removal of users reaction,
|
||||
// ownership needs to be checked, so only owned
|
||||
// reactions can be removed upon click
|
||||
|
||||
if (reactionItem.reactionVoter.actorId.equals(userEntity!!.userId)){
|
||||
deleteReaction(chatMessage, reactionItem.reaction!!)
|
||||
}
|
||||
|
||||
dismiss()
|
||||
}
|
||||
|
||||
private fun deleteReaction(message: ChatMessage, emoji: String) {
|
||||
val credentials = ApiUtils.getCredentials(userEntity?.username, userEntity?.token)
|
||||
|
||||
ncApi.deleteReaction(
|
||||
credentials,
|
||||
ApiUtils.getUrlForMessageReaction(
|
||||
userEntity?.baseUrl,
|
||||
currentConversation!!.token,
|
||||
message.id
|
||||
),
|
||||
emoji
|
||||
)
|
||||
?.subscribeOn(Schedulers.io())
|
||||
?.observeOn(AndroidSchedulers.mainThread())
|
||||
?.subscribe(object : Observer<GenericOverall> {
|
||||
override fun onSubscribe(d: Disposable) {
|
||||
}
|
||||
|
||||
override fun onNext(@NonNull genericOverall: GenericOverall) {
|
||||
Log.d(TAG, "deleted reaction: $emoji")
|
||||
}
|
||||
|
||||
override fun onError(e: Throwable) {
|
||||
Log.e(TAG, "error while deleting reaction: $emoji")
|
||||
}
|
||||
|
||||
override fun onComplete() {
|
||||
dismiss()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val TAG = "ShowReactionsDialog"
|
||||
const val EMOJI_MARGIN: Float = 8F
|
||||
|
Loading…
Reference in New Issue
Block a user