Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix toggleReaction #109

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pubnub-chat-api/api/pubnub-chat-api.api
Original file line number Diff line number Diff line change
Expand Up @@ -366,12 +366,13 @@ public final class com/pubnub/chat/config/ChatConfigurationKt {

public final class com/pubnub/chat/config/CustomPayloads {
public fun <init> ()V
public fun <init> (Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Ljava/lang/String;Ljava/lang/String;)V
public synthetic fun <init> (Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Ljava/lang/String;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun <init> (Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
public synthetic fun <init> (Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun getDeleteMessageActionName ()Ljava/lang/String;
public final fun getEditMessageActionName ()Ljava/lang/String;
public final fun getGetMessagePublishBody ()Lkotlin/jvm/functions/Function3;
public final fun getGetMessageResponseBody ()Lkotlin/jvm/functions/Function3;
public final fun getReactionsActionName ()Ljava/lang/String;
}

public final class com/pubnub/chat/config/LogLevel : java/lang/Enum {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,5 @@ class CustomPayloads(
*
*/
val deleteMessageActionName: String? = null,
val reactionsActionName: String? = null
)
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ class ChatImpl(
?: MessageActionType.EDITED.toString(),
override val deleteMessageActionName: String = config.customPayloads?.deleteMessageActionName
?: MessageActionType.DELETED.toString(),
override val reactionsActionName: String = config.customPayloads?.reactionsActionName
?: MessageActionType.REACTIONS.toString(),
override val timerManager: TimerManager = createTimerManager()
) : ChatInternal {
override var currentUser: User =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import com.pubnub.kmp.PNFuture
interface ChatInternal : Chat {
val editMessageActionName: String
val deleteMessageActionName: String
val reactionsActionName: String
val timerManager: TimerManager

fun createUser(user: User): PNFuture<User>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import com.pubnub.chat.internal.util.logWarnAndReturnException
import com.pubnub.chat.internal.util.pnError
import com.pubnub.chat.types.EventContent
import com.pubnub.chat.types.File
import com.pubnub.chat.types.MessageActionType
import com.pubnub.chat.types.MessageMentionedUser
import com.pubnub.chat.types.MessageMentionedUsers
import com.pubnub.chat.types.MessageReferencedChannel
Expand Down Expand Up @@ -93,7 +92,7 @@ abstract class BaseMessage<T : Message>(
get() = content.files ?: emptyList()

override val reactions: Map<String, List<PNFetchMessageItem.Action>>
get() = actions?.get(MessageActionType.REACTIONS.toString()) ?: emptyMap()
get() = actions?.get(chat.reactionsActionName) ?: emptyMap()

override val textLinks: List<TextLink>? get() = (
meta?.get(
Expand Down Expand Up @@ -209,7 +208,10 @@ abstract class BaseMessage<T : Message>(
it.uuid == chat.currentUser.id
}
val messageAction =
PNMessageAction(MessageActionType.REACTIONS.toString(), reaction, timetoken)
PNMessageAction(chat.reactionsActionName, reaction, timetoken).apply {
actionTimetoken = existingReaction?.actionTimetoken
uuid = chat.currentUser.id
}
val newActions = if (existingReaction != null) {
chat.pubNub.removeMessageAction(channelId, timetoken, existingReaction.actionTimetoken.toLong())
.then { filterAction(actions, messageAction) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ abstract class FakeChat(override val config: ChatConfiguration, override val pub
TODO("Not yet implemented")
}

override val reactionsActionName: String
get() = TODO("Not yet implemented")

override val currentUser: User
get() = TODO("Not yet implemented")

Expand Down
Loading