Skip to content

Commit

Permalink
Merge branch 'develop' into feature/threads_v2_xml
Browse files Browse the repository at this point in the history
  • Loading branch information
PetarVelikov committed Dec 12, 2024
2 parents 2ef9043 + 9cf8391 commit d1a542f
Show file tree
Hide file tree
Showing 43 changed files with 893 additions and 28 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
### ⬆️ Improved

### ✅ Added
- Add `Channel.membership.pinnedAt` property notifiying if/when a channel was pinned by the current user. [#5513](https://github.com/GetStream/stream-chat-android/pull/5513)
- Add `Channel.membership.archiveAt` property notifiying if/when a channel was archived by the current user. [#5513](https://github.com/GetStream/stream-chat-android/pull/5513)

### ⚠️ Changed

Expand All @@ -16,6 +18,10 @@
### ⬆️ Improved

### ✅ Added
- Add `ChatClient.pinChannel` and `ChannelClient.unpinChannel` methods to pin/unpin a channel. [#5513](https://github.com/GetStream/stream-chat-android/pull/5513)
- Add `ChatClient.archiveChannel` and `ChannelClient.unarchiveChannel` methods to archive/unarchive a channel. [#5513](https://github.com/GetStream/stream-chat-android/pull/5513)
- Add `ChannelClient.pinChannel` and `ChannelClient.unpinChannel` methods to pin/unpin a channel. [#5513](https://github.com/GetStream/stream-chat-android/pull/5513)
- Add `ChannelClient.archiveChannel` and `ChannelClient.unarchiveChannel` methods to archive/unarchive a channel. [#5513](https://github.com/GetStream/stream-chat-android/pull/5513)

### ⚠️ Changed

Expand Down Expand Up @@ -75,6 +81,8 @@
### ✅ Added
- The `StreamAttachmentFactories.defaultFactories()` method now accepts a `skipTypes` parameter to skip specific factory types. [#5494](https://github.com/GetStream/stream-chat-android/pull/5494)
- Add `ChatTheme.keyboardBehaviour` property to customize different keyboard behaviours. [#5506](https://github.com/GetStream/stream-chat-android/pull/5506)
- Add `MessageOptionItemVisibility.isBlockUserVisible` property to show/hide the block user option. [#5512](https://github.com/GetStream/stream-chat-android/pull/5512)
- Add `ChatTheme.channelOptionsTheme` property to customize the channel options. [#5513](https://github.com/GetStream/stream-chat-android/pull/5513)

### ⚠️ Changed

Expand Down
11 changes: 11 additions & 0 deletions stream-chat-android-client/api/stream-chat-android-client.api
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public final class io/getstream/chat/android/client/ChatClient {
public static synthetic fun addMembers$default (Lio/getstream/chat/android/client/ChatClient;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Lio/getstream/chat/android/models/Message;Ljava/lang/Boolean;Ljava/lang/Boolean;ILjava/lang/Object;)Lio/getstream/result/call/Call;
public final fun addSocketListener (Lio/getstream/chat/android/client/socket/SocketListener;)V
public final fun appSettings ()Lio/getstream/result/call/Call;
public final fun archiveChannel (Ljava/lang/String;Ljava/lang/String;)Lio/getstream/result/call/Call;
public final fun banUser (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Integer;)Lio/getstream/result/call/Call;
public final fun blockUser (Ljava/lang/String;)Lio/getstream/result/call/Call;
public final fun castPollAnswer (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lio/getstream/result/call/Call;
Expand Down Expand Up @@ -92,6 +93,7 @@ public final class io/getstream/chat/android/client/ChatClient {
public static final fun instance ()Lio/getstream/chat/android/client/ChatClient;
public final fun inviteMembers (Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Lio/getstream/chat/android/models/Message;Ljava/lang/Boolean;)Lio/getstream/result/call/Call;
public static synthetic fun inviteMembers$default (Lio/getstream/chat/android/client/ChatClient;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Lio/getstream/chat/android/models/Message;Ljava/lang/Boolean;ILjava/lang/Object;)Lio/getstream/result/call/Call;
public static final fun isInitialized ()Z
public final fun isSocketConnected ()Z
public final fun keystroke (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lio/getstream/result/call/Call;
public static synthetic fun keystroke$default (Lio/getstream/chat/android/client/ChatClient;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Lio/getstream/result/call/Call;
Expand All @@ -116,6 +118,7 @@ public final class io/getstream/chat/android/client/ChatClient {
public static synthetic fun partialUpdateThread$default (Lio/getstream/chat/android/client/ChatClient;Ljava/lang/String;Ljava/util/Map;Ljava/util/List;ILjava/lang/Object;)Lio/getstream/result/call/Call;
public final fun partialUpdateUser (Ljava/lang/String;Ljava/util/Map;Ljava/util/List;)Lio/getstream/result/call/Call;
public static synthetic fun partialUpdateUser$default (Lio/getstream/chat/android/client/ChatClient;Ljava/lang/String;Ljava/util/Map;Ljava/util/List;ILjava/lang/Object;)Lio/getstream/result/call/Call;
public final fun pinChannel (Ljava/lang/String;Ljava/lang/String;)Lio/getstream/result/call/Call;
public final fun pinMessage (Lio/getstream/chat/android/models/Message;I)Lio/getstream/result/call/Call;
public final fun pinMessage (Lio/getstream/chat/android/models/Message;Ljava/util/Date;)Lio/getstream/result/call/Call;
public static synthetic fun pinMessage$default (Lio/getstream/chat/android/client/ChatClient;Lio/getstream/chat/android/models/Message;Ljava/util/Date;ILjava/lang/Object;)Lio/getstream/result/call/Call;
Expand Down Expand Up @@ -190,13 +193,15 @@ public final class io/getstream/chat/android/client/ChatClient {
public final fun translate (Ljava/lang/String;Ljava/lang/String;)Lio/getstream/result/call/Call;
public final fun truncateChannel (Ljava/lang/String;Ljava/lang/String;Lio/getstream/chat/android/models/Message;)Lio/getstream/result/call/Call;
public static synthetic fun truncateChannel$default (Lio/getstream/chat/android/client/ChatClient;Ljava/lang/String;Ljava/lang/String;Lio/getstream/chat/android/models/Message;ILjava/lang/Object;)Lio/getstream/result/call/Call;
public final fun unarchiveChannel (Ljava/lang/String;Ljava/lang/String;)Lio/getstream/result/call/Call;
public final fun unbanUser (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lio/getstream/result/call/Call;
public final fun unblockUser (Ljava/lang/String;)Lio/getstream/result/call/Call;
public final fun unflagMessage (Ljava/lang/String;)Lio/getstream/result/call/Call;
public final fun unflagUser (Ljava/lang/String;)Lio/getstream/result/call/Call;
public final fun unmuteChannel (Ljava/lang/String;Ljava/lang/String;)Lio/getstream/result/call/Call;
public final fun unmuteCurrentUser ()Lio/getstream/result/call/Call;
public final fun unmuteUser (Ljava/lang/String;)Lio/getstream/result/call/Call;
public final fun unpinChannel (Ljava/lang/String;Ljava/lang/String;)Lio/getstream/result/call/Call;
public final fun unpinMessage (Lio/getstream/chat/android/models/Message;)Lio/getstream/result/call/Call;
public final fun updateChannel (Ljava/lang/String;Ljava/lang/String;Lio/getstream/chat/android/models/Message;Ljava/util/Map;)Lio/getstream/result/call/Call;
public static synthetic fun updateChannel$default (Lio/getstream/chat/android/client/ChatClient;Ljava/lang/String;Ljava/lang/String;Lio/getstream/chat/android/models/Message;Ljava/util/Map;ILjava/lang/Object;)Lio/getstream/result/call/Call;
Expand Down Expand Up @@ -630,6 +635,7 @@ public final class io/getstream/chat/android/client/channel/ChannelClient {
public final fun acceptInvite (Ljava/lang/String;)Lio/getstream/result/call/Call;
public final fun addMembers (Ljava/util/List;Lio/getstream/chat/android/models/Message;Ljava/lang/Boolean;Ljava/lang/Boolean;)Lio/getstream/result/call/Call;
public static synthetic fun addMembers$default (Lio/getstream/chat/android/client/channel/ChannelClient;Ljava/util/List;Lio/getstream/chat/android/models/Message;Ljava/lang/Boolean;Ljava/lang/Boolean;ILjava/lang/Object;)Lio/getstream/result/call/Call;
public final fun archive ()Lio/getstream/result/call/Call;
public final fun banUser (Ljava/lang/String;Ljava/lang/String;Ljava/lang/Integer;)Lio/getstream/result/call/Call;
public final fun create (Ljava/util/List;Ljava/util/Map;)Lio/getstream/result/call/Call;
public final fun delete ()Lio/getstream/result/call/Call;
Expand Down Expand Up @@ -674,6 +680,7 @@ public final class io/getstream/chat/android/client/channel/ChannelClient {
public static synthetic fun muteUser$default (Lio/getstream/chat/android/client/channel/ChannelClient;Ljava/lang/String;Ljava/lang/Integer;ILjava/lang/Object;)Lio/getstream/result/call/Call;
public final fun partialUpdateMember (Ljava/lang/String;Ljava/util/Map;Ljava/util/List;)Lio/getstream/result/call/Call;
public static synthetic fun partialUpdateMember$default (Lio/getstream/chat/android/client/channel/ChannelClient;Ljava/lang/String;Ljava/util/Map;Ljava/util/List;ILjava/lang/Object;)Lio/getstream/result/call/Call;
public final fun pin ()Lio/getstream/result/call/Call;
public final fun pinMessage (Lio/getstream/chat/android/models/Message;I)Lio/getstream/result/call/Call;
public final fun pinMessage (Lio/getstream/chat/android/models/Message;Ljava/util/Date;)Lio/getstream/result/call/Call;
public final fun query (Lio/getstream/chat/android/client/api/models/QueryChannelRequest;)Lio/getstream/result/call/Call;
Expand Down Expand Up @@ -723,10 +730,12 @@ public final class io/getstream/chat/android/client/channel/ChannelClient {
public final fun truncate ()Lio/getstream/result/call/Call;
public final fun truncate (Lio/getstream/chat/android/models/Message;)Lio/getstream/result/call/Call;
public static synthetic fun truncate$default (Lio/getstream/chat/android/client/channel/ChannelClient;Lio/getstream/chat/android/models/Message;ILjava/lang/Object;)Lio/getstream/result/call/Call;
public final fun unarchive ()Lio/getstream/result/call/Call;
public final fun unbanUser (Ljava/lang/String;)Lio/getstream/result/call/Call;
public final fun unmute ()Lio/getstream/result/call/Call;
public final fun unmuteCurrentUser ()Lio/getstream/result/call/Call;
public final fun unmuteUser (Ljava/lang/String;)Lio/getstream/result/call/Call;
public final fun unpin ()Lio/getstream/result/call/Call;
public final fun unpinMessage (Lio/getstream/chat/android/models/Message;)Lio/getstream/result/call/Call;
public final fun update (Lio/getstream/chat/android/models/Message;Ljava/util/Map;)Lio/getstream/result/call/Call;
public static synthetic fun update$default (Lio/getstream/chat/android/client/channel/ChannelClient;Lio/getstream/chat/android/models/Message;Ljava/util/Map;ILjava/lang/Object;)Lio/getstream/result/call/Call;
Expand Down Expand Up @@ -2487,7 +2496,9 @@ public final class io/getstream/chat/android/client/extensions/ChannelExtensionK
public static final fun countUnreadMentionsForUser (Lio/getstream/chat/android/models/Channel;Lio/getstream/chat/android/models/User;)I
public static final fun getCurrentUserUnreadCount (Lio/getstream/chat/android/models/Channel;)I
public static final fun isAnonymousChannel (Lio/getstream/chat/android/models/Channel;)Z
public static final fun isArchive (Lio/getstream/chat/android/models/Channel;)Z
public static final fun isMutedFor (Lio/getstream/chat/android/models/Channel;Lio/getstream/chat/android/models/User;)Z
public static final fun isPinned (Lio/getstream/chat/android/models/Channel;)Z
public static final fun syncUnreadCountWithReads (Lio/getstream/chat/android/models/Channel;)Lio/getstream/chat/android/models/Channel;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1944,6 +1944,92 @@ internal constructor(
)
}

/**
* Pin the channel for the current user.
*
* @param channelType The channel type.
* @param channelId The channel ID.
*
* @return Executable async [Call] responsible for pinning the channel.
*/
public fun pinChannel(
channelType: String,
channelId: String,
): Call<Member> {
logger.d { "[pinChannel] channelType: $channelType, channelId: $channelId" }
val set = mapOf("pinned" to true)
return partialUpdateMember(
channelType = channelType,
channelId = channelId,
userId = getCurrentUser()?.id ?: "",
set = set,
)
}

/**
* Unpin the channel for the current user.
*
* @param channelType The channel type.
* @param channelId The channel ID.
*
* @return Executable async [Call] responsible for unpinning the channel.
*/
public fun unpinChannel(
channelType: String,
channelId: String,
): Call<Member> {
logger.d { "[unpinChannel] channelType: $channelType, channelId: $channelId" }
return partialUpdateMember(
channelType = channelType,
channelId = channelId,
userId = getCurrentUser()?.id ?: "",
unset = listOf("pinned"),
)
}

/**
* Archive the channel for the current user.
*
* @param channelType The channel type.
* @param channelId The channel ID.
*
* @return Executable async [Call] responsible for archiving the channel.
*/
public fun archiveChannel(
channelType: String,
channelId: String,
): Call<Member> {
logger.d { "[archiveChannel] channelType: $channelType, channelId: $channelId" }
val set = mapOf("archived" to true)
return partialUpdateMember(
channelType = channelType,
channelId = channelId,
userId = getCurrentUser()?.id ?: "",
set = set,
)
}

/**
* Unarchive the channel for the current user.
*
* @param channelType The channel type.
* @param channelId The channel ID.
*
* @return Executable async [Call] responsible for un-archiving the channel.
*/
public fun unarchiveChannel(
channelType: String,
channelId: String,
): Call<Member> {
logger.d { "[unarchiveChannel]channelType: $channelType, channelId: $channelId" }
return partialUpdateMember(
channelType = channelType,
channelId = channelId,
userId = getCurrentUser()?.id ?: "",
unset = listOf("archived"),
)
}

/**
* Pins the message.
*
Expand Down Expand Up @@ -3821,6 +3907,7 @@ internal constructor(
)
}

@JvmStatic
public val isInitialized: Boolean
get() = instance != null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ internal class ExtraDataValidator(
"notifications_muted",
"status",
"ban_expires",
"pinned_at",
"archived_at",
)

private val reservedInChannelPredicate: (String) -> Boolean = reservedInChannel::contains
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ internal fun DownstreamMemberDto.toDomain(currentUserId: UserId?): Member =
notificationsMuted = notifications_muted,
status = status,
banExpires = ban_expires,
pinnedAt = pinned_at,
archivedAt = archived_at,
extraData = extraData,
)

Expand All @@ -52,5 +54,7 @@ internal fun Member.toDto(): UpstreamMemberDto =
notifications_muted = notificationsMuted,
status = status,
ban_expires = banExpires,
pinned_at = pinnedAt,
archived_at = archivedAt,
extraData = extraData,
)
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ internal data class UpstreamMemberDto(
val notifications_muted: Boolean?,
val status: String?,
val ban_expires: Date?,

val pinned_at: Date?,
val archived_at: Date?,
val extraData: Map<String, Any>,
) : ExtraDataDto

Expand All @@ -68,6 +69,7 @@ internal data class DownstreamMemberDto(
val notifications_muted: Boolean?,
val status: String?,
val ban_expires: Date?,

val pinned_at: Date?,
val archived_at: Date?,
val extraData: Map<String, Any>,
) : ExtraDataDto
Original file line number Diff line number Diff line change
Expand Up @@ -967,4 +967,36 @@ public class ChannelClient internal constructor(

@CheckResult
public fun unpinMessage(message: Message): Call<Message> = client.unpinMessage(message)

/**
* Pins the channel for the current user.
*
* @return Executable async [Call] responsible for pinning the channel.
*/
@CheckResult
public fun pin(): Call<Member> = client.pinChannel(channelType, channelId)

/**
* Unpins the channel for the current user.
*
* @return Executable async [Call] responsible for unpinning the channel.
*/
@CheckResult
public fun unpin(): Call<Member> = client.unpinChannel(channelType, channelId)

/**
* Archives the channel for the current user.
*
* @return Executable async [Call] responsible for archiving the channel.
*/
@CheckResult
public fun archive(): Call<Member> = client.archiveChannel(channelType, channelId)

/**
* Un-archives the channel for the current user.
*
* @return Executable async [Call] responsible for un-archiving the channel.
*/
@CheckResult
public fun unarchive(): Call<Member> = client.unarchiveChannel(channelType, channelId)
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@ import io.getstream.chat.android.models.User

public fun Channel.isAnonymousChannel(): Boolean = id.isAnonymousChannelId()

/**
* Checks if the channel is pinned or not for the current user.
*
* @return True if the channel is pinned for the current user.
*/
public fun Channel.isPinned(): Boolean = membership?.pinnedAt != null

/**
* Checks if the channel is archived or not for the current user.
*
* @return True if the channel is archived for the current user.
*/
public fun Channel.isArchive(): Boolean = membership?.archivedAt != null

/**
* Checks if [Channel] is muted for [user].
*
Expand Down
Loading

0 comments on commit d1a542f

Please sign in to comment.