Merge branch 'develop' into merge/main_to_develop

This commit is contained in:
pavelprystinka 2023-03-10 11:43:15 -08:00 коммит произвёл GitHub
Родитель 9b39c17256 8eb7b1b494
Коммит 6f6441d2bd
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
16 изменённых файлов: 58 добавлений и 70 удалений

Просмотреть файл

@ -6,7 +6,8 @@ buildscript {
ext {
call_library_version_name = '1.2.0'
chat_library_version_name = '1.0.0-beta.1'
chat_library_version_name = '1.0.0-beta.2'
ui_library_version_code = getVersionCode()

Просмотреть файл

@ -4,7 +4,7 @@
## Latest Release
- Public Preview: [1.0.0-beta.1](https://github.com/Azure/communication-ui-library-android/releases/tag/chat-1.0.0-beta.1)
- Public Preview: [1.0.0-beta.2](https://github.com/Azure/communication-ui-library-android/releases/tag/chat-1.0.0-beta.2)
## Getting Started
@ -27,7 +27,7 @@ android {
```groovy
dependencies {
...
implementation 'com.azure.android:azure-communication-ui-chat:1.0.0-beta.1'
implementation 'com.azure.android:azure-communication-ui-chat:1.0.0-beta.2'
...
}
```

Просмотреть файл

@ -7,7 +7,7 @@ internal class DiagnosticConfig {
val tag: String by lazy { getApplicationId() }
private fun getApplicationId(): String {
val chatCompositeVersionName = "1.0.0-beta.1"
val chatCompositeVersionName = "1.0.0-beta.2"
val baseTag = "ac"
// Tag template is: acXYYY/<version>
// Where:

Просмотреть файл

@ -21,12 +21,4 @@ internal class ChatCompositeEventHandlerRepository {
fun getLocalParticipantRemovedHandlers(): List<ChatCompositeEventHandler<String>> {
return eventHandlers
}
fun addLocalParticipantRemovedEventHandler(handler: ChatCompositeEventHandler<String>) {
eventHandlers.add(handler)
}
fun removeLocalParticipantRemovedEventHandler(handler: ChatCompositeEventHandler<String>) {
eventHandlers.remove(handler)
}
}

Просмотреть файл

@ -45,7 +45,8 @@ internal fun com.azure.android.communication.chat.models.ChatMessage.into(localP
participants = this.content.participants?.map {
RemoteParticipantInfoModel(
userIdentifier = it.communicationIdentifier.into(),
displayName = it.displayName
displayName = it.displayName,
isLocalUser = it.communicationIdentifier.into().id == localParticipantIdentifier
)
}?.toList() ?: emptyList(),
internalId = null,

Просмотреть файл

@ -8,4 +8,5 @@ import com.azure.android.communication.ui.chat.service.sdk.wrapper.Communication
internal data class RemoteParticipantInfoModel(
val userIdentifier: CommunicationIdentifier,
val displayName: String?,
val isLocalUser: Boolean = false
)

Просмотреть файл

@ -10,9 +10,8 @@ internal sealed class ParticipantAction : Action {
class ParticipantsAdded(val participants: List<RemoteParticipantInfoModel>) :
ParticipantAction()
class ParticipantsRemoved(val participants: List<RemoteParticipantInfoModel>, val localParticipantRemoved: Boolean) :
class ParticipantsRemoved(val participants: List<RemoteParticipantInfoModel>) :
ParticipantAction()
class AddParticipantTyping(val infoModel: ParticipantTimestampInfoModel) : ParticipantAction()
class RemoveParticipantTyping(val infoModel: ParticipantTimestampInfoModel) :
ParticipantAction()

Просмотреть файл

@ -50,13 +50,10 @@ internal class MessageRepositoryMiddlewareImpl(
store::dispatch
)
is ParticipantAction.ParticipantsRemoved -> {
processParticipantsRemoved(
action,
store.getCurrentState().participantState.localParticipantInfoModel.userIdentifier,
store::dispatch,
)
if (action.localParticipantRemoved) {
processLocalParticipantRemoved(action, store::dispatch)
if (action.participants.any { it.isLocalUser }) {
processLocalParticipantRemoved(store::dispatch)
} else {
processParticipantsRemoved(action, store::dispatch)
}
}
is NetworkAction.Disconnected -> processNetworkDisconnected(store::dispatch)
@ -167,44 +164,35 @@ internal class MessageRepositoryMiddlewareImpl(
private fun processParticipantsRemoved(
action: ParticipantAction.ParticipantsRemoved,
localUserId: String,
dispatch: Dispatch,
) {
val participants = action.participants.filter { it.userIdentifier.id != localUserId }
if (participants.isNotEmpty()) {
messageRepository.addMessage(
MessageInfoModel(
internalId = System.currentTimeMillis().toString(),
participants = participants,
content = null,
createdOn = OffsetDateTime.now(),
senderDisplayName = null,
messageType = ChatMessageType.PARTICIPANT_REMOVED,
)
messageRepository.addMessage(
MessageInfoModel(
internalId = System.currentTimeMillis().toString(),
participants = action.participants,
content = null,
createdOn = OffsetDateTime.now(),
senderDisplayName = null,
messageType = ChatMessageType.PARTICIPANT_REMOVED,
)
notifyUpdate(dispatch)
}
)
notifyUpdate(dispatch)
}
private fun processLocalParticipantRemoved(
action: ParticipantAction.ParticipantsRemoved,
dispatch: Dispatch,
) {
if (action.localParticipantRemoved) {
messageRepository.addMessage(
MessageInfoModel(
internalId = System.currentTimeMillis().toString(),
isCurrentUser = true,
content = null,
createdOn = OffsetDateTime.now(),
senderDisplayName = null,
messageType = ChatMessageType.PARTICIPANT_REMOVED,
)
messageRepository.addMessage(
MessageInfoModel(
internalId = System.currentTimeMillis().toString(),
isCurrentUser = true,
content = null,
createdOn = OffsetDateTime.now(),
senderDisplayName = null,
messageType = ChatMessageType.PARTICIPANT_REMOVED,
)
notifyUpdate(dispatch)
}
)
notifyUpdate(dispatch)
}
private fun processDeletedMessage(action: ChatAction.MessageDeleted, dispatch: Dispatch) {

Просмотреть файл

@ -12,7 +12,6 @@ import com.azure.android.communication.ui.chat.models.MessageInfoModel
import com.azure.android.communication.ui.chat.models.MessagesPageModel
import com.azure.android.communication.ui.chat.models.ParticipantTimestampInfoModel
import com.azure.android.communication.ui.chat.models.RemoteParticipantsInfoModel
import com.azure.android.communication.ui.chat.models.RemoteParticipantInfoModel
import com.azure.android.communication.ui.chat.redux.Dispatch
import com.azure.android.communication.ui.chat.redux.Store
import com.azure.android.communication.ui.chat.redux.action.ChatAction
@ -160,11 +159,7 @@ internal class ChatServiceListener(
dispatch(
ParticipantAction.ParticipantsRemoved(
participants = it.infoModel.participants,
localParticipantRemoved = isLocalParticipantRemoved(
it.infoModel.participants,
localParticipantInfoModel
)
participants = it.infoModel.participants
)
)
}
@ -173,10 +168,4 @@ internal class ChatServiceListener(
}
}
}
private fun isLocalParticipantRemoved(
participants: List<RemoteParticipantInfoModel>,
localParticipantInfoModel: LocalParticipantInfoModel,
) =
participants.any { it.userIdentifier.id == localParticipantInfoModel.userIdentifier }
}

Просмотреть файл

@ -31,6 +31,7 @@ internal class ParticipantsReducerImpl : ParticipantsReducer {
is ParticipantAction.ParticipantsRemoved -> {
val participantTypingKeys = state.participantTyping.keys
val removedParticipants = action.participants.map { it.userIdentifier.id }
var hasLocalParticipant = action.participants.any { it.isLocalUser }
var participantTyping = state.participantTyping
// TODO: improve this logic
removedParticipants.forEach { id ->
@ -40,7 +41,7 @@ internal class ParticipantsReducerImpl : ParticipantsReducer {
var updatedState = state
if (action.localParticipantRemoved) {
if (hasLocalParticipant) {
updatedState = updatedState.copy(
localParticipantInfoModel =
state.localParticipantInfoModel.copy(isActiveChatThreadParticipant = false)

Просмотреть файл

@ -193,7 +193,8 @@ internal class ChatEventHandler {
participants = event.participantsAdded.map {
RemoteParticipantInfoModel(
userIdentifier = it.communicationIdentifier.into(),
displayName = it.displayName
displayName = it.displayName,
isLocalUser = it.communicationIdentifier.into().id == this.localParticipantIdentifier
)
}
)
@ -210,7 +211,8 @@ internal class ChatEventHandler {
participants = event.participantsRemoved.map {
RemoteParticipantInfoModel(
userIdentifier = it.communicationIdentifier.into(),
displayName = it.displayName
displayName = it.displayName,
isLocalUser = it.communicationIdentifier.into().id == this.localParticipantIdentifier
)
}
)

Просмотреть файл

@ -71,7 +71,8 @@ internal class ChatFetchNotificationHandler(coroutineContextProvider: CoroutineC
participants = message.content.participants.map {
RemoteParticipantInfoModel(
userIdentifier = it.communicationIdentifier.into(),
displayName = it.displayName
displayName = it.displayName,
isLocalUser = it.communicationIdentifier.into().id == this.localParticipantIdentifier
)
}
)
@ -88,7 +89,8 @@ internal class ChatFetchNotificationHandler(coroutineContextProvider: CoroutineC
participants = message.content.participants.map {
RemoteParticipantInfoModel(
userIdentifier = it.communicationIdentifier.into(),
displayName = it.displayName
displayName = it.displayName,
isLocalUser = it.communicationIdentifier.into().id == this.localParticipantIdentifier
)
}
)

Просмотреть файл

@ -202,7 +202,8 @@ internal class ChatSDKWrapper(
participants.add(
RemoteParticipantInfoModel(
userIdentifier = it.communicationIdentifier.into(),
displayName = it.displayName
displayName = it.displayName,
isLocalUser = it.communicationIdentifier.into().id == localParticipantIdentifier
)
)
}

Просмотреть файл

@ -355,7 +355,7 @@ class ParticipantsReducerUnitTest {
mutableSetOf(),
)
val action =
ParticipantAction.ParticipantsRemoved(participants = listOf(userThree, userFour), false)
ParticipantAction.ParticipantsRemoved(participants = listOf(userThree, userFour))
// act
val newState = reducer.reduce(previousState, action)

Просмотреть файл

@ -32,6 +32,7 @@
android:exported="true"
android:label="@string/azure_communication_ui_chat_demo_app_title"
android:theme="@style/Launcher.Theme"
android:windowSoftInputMode="adjustResize"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Просмотреть файл

@ -1,3 +1,13 @@
# Release History
## 1.0.0-beta.2 (2023-03-01)
### Bugs Fixed
- Fixed an issue in demo app where sendbox does not appear to have sufficient padding. [#714](https://github.com/Azure/communication-ui-library-android/pull/714)
### Other Changes
- Refactored the internal logic for local user removal scenarios. [#711](https://github.com/Azure/communication-ui-library-android/pull/711)
## 1.0.0-beta.1 (2023-01-10)
This is the initial release of Azure Communication UI Chat Library. For more information, please see the [README][read_me] and [QuickStart][documentation].