Skip to content

chore: Don't authenticate loading avatars #460

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

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
2 changes: 1 addition & 1 deletion Coil/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ android {
}

dependencies {
implementation(project(":Core:Auth"))
api(project(":Core:Auth"))
implementation(project(":Core:Avatar"))
implementation(project(":Core:Network"))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
Expand All @@ -46,6 +47,7 @@ import coil3.compose.AsyncImage
import coil3.request.ImageRequest
import coil3.request.crossfade
import com.infomaniak.core.avatar.getBackgroundColorResBasedOnId
import com.infomaniak.core.coil.ImageLoaderProvider
import com.infomaniak.core.useravatar.AvatarData
import com.infomaniak.core.useravatar.AvatarDisplayState
import com.infomaniak.core.useravatar.component.InitialsTextAvatar
Expand All @@ -71,14 +73,17 @@ fun UserAvatar(modifier: Modifier = Modifier, avatarData: AvatarData, border: Bo
AvatarDisplayState.Initials -> InitialsTextAvatar(avatarData)
AvatarDisplayState.UnknownUser -> UnknownUserIcon(avatarData.iconColor)
AvatarDisplayState.Avatar -> {
val imageRequest = ImageRequest.Builder(LocalContext.current)
val context = LocalContext.current
val unauthenticatedImageLoader = remember(context) { ImageLoaderProvider.newImageLoader(context) }
val imageRequest = ImageRequest.Builder(context )
.data(avatarData.uri)
.crossfade(true)
.build()

AsyncImage(
model = imageRequest,
contentDescription = null,
imageLoader = unauthenticatedImageLoader,
contentScale = ContentScale.Crop,
onError = { avatarDisplayState = computeAvatarState(avatarData, hasLoadingFailed = true) },
)
Expand Down