Skip to content

Commit

Permalink
Code review
Browse files Browse the repository at this point in the history
  • Loading branch information
m-zagorski committed Dec 17, 2024
1 parent 53bd397 commit 7366468
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,8 @@ private fun SelfUserProfileContent(
modifier = Modifier.padding(dimensions().spacing16x),
verticalArrangement = Arrangement.spacedBy(dimensions().spacing8x)
) {
if (isTeamAdminOrOwner) {
ManageTeamButton(uriHandler::openUri)
if (teamUrl != null) {
ManageTeamButton { uriHandler.openUri(teamUrl) }
}
NewTeamButton(onAddAccountClick, isUserInCall, context)
}
Expand Down Expand Up @@ -451,15 +451,12 @@ private fun CurrentSelfUserStatus(

@Composable
private fun ManageTeamButton(
onManageTeamClick: (String) -> Unit
onManageTeamClick: () -> Unit
) {
val teamManagementLink = stringResource(R.string.url_team_management_login)
WireSecondaryButton(
text = stringResource(R.string.user_profile_account_management),
onClickDescription = stringResource(R.string.content_description_self_profile_manage_team_btn),
onClick = {
onManageTeamClick(teamManagementLink)
}
onClick = onManageTeamClick
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ data class SelfUserProfileState(
val fullName: String = "",
val userName: String = "",
val teamName: String? = "", // maybe teamId is better here
val isTeamAdminOrOwner: Boolean = false,
val teamUrl: String? = null,
val otherAccounts: List<OtherAccount> = emptyList(),
val statusDialogData: StatusDialogData? = null, // null means no dialog to display
val isAvatarLoading: Boolean = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import com.wire.kalium.logic.feature.call.usecase.ObserveEstablishedCallsUseCase
import com.wire.kalium.logic.feature.legalhold.LegalHoldStateForSelfUser
import com.wire.kalium.logic.feature.legalhold.ObserveLegalHoldStateForSelfUserUseCase
import com.wire.kalium.logic.feature.personaltoteamaccount.CanMigrateFromPersonalToTeamUseCase
import com.wire.kalium.logic.feature.server.GetTeamUrlUseCase
import com.wire.kalium.logic.feature.team.GetUpdatedSelfTeamUseCase
import com.wire.kalium.logic.feature.user.GetSelfUserUseCase
import com.wire.kalium.logic.feature.user.IsReadOnlyAccountUseCase
Expand Down Expand Up @@ -99,7 +100,8 @@ class SelfUserProfileViewModel @Inject constructor(
private val notificationManager: WireNotificationManager,
private val globalDataStore: GlobalDataStore,
private val qualifiedIdMapper: QualifiedIdMapper,
private val anonymousAnalyticsManager: AnonymousAnalyticsManager
private val anonymousAnalyticsManager: AnonymousAnalyticsManager,
private val getTeamUrl: GetTeamUrlUseCase
) : ViewModel() {

var userProfileState by mutableStateOf(SelfUserProfileState(userId = selfUserId, isAvatarLoading = true))
Expand Down Expand Up @@ -177,7 +179,7 @@ class SelfUserProfileViewModel @Inject constructor(
fullName = name.orEmpty(),
userName = handle.orEmpty(),
teamName = selfTeam?.name,
isTeamAdminOrOwner = userType == UserType.OWNER || userType == UserType.ADMIN,
teamUrl = getTeamUrl().takeIf { userType == UserType.OWNER || userType == UserType.ADMIN },
otherAccounts = otherAccounts,
avatarAsset = userProfileState.avatarAsset,
isAvatarLoading = false,
Expand Down

0 comments on commit 7366468

Please sign in to comment.