mirror of https://github.com/Ashinch/ReadYou.git
feat(ui, ReaderImageViewer): add referer header with domain extraction for image proxying
This commit is contained in:
parent
e795daedc8
commit
1578ba6887
|
@ -41,8 +41,9 @@ import androidx.compose.ui.window.DialogWindowProvider
|
|||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.HapticFeedbackConstantsCompat
|
||||
import coil.compose.rememberAsyncImagePainter
|
||||
|
||||
import coil.request.ImageRequest
|
||||
import me.ash.reader.R
|
||||
import me.ash.reader.ui.ext.extractDomain
|
||||
import me.ash.reader.ui.ext.showToast
|
||||
import me.saket.telephoto.zoomable.ZoomSpec
|
||||
import me.saket.telephoto.zoomable.ZoomableContentLocation
|
||||
|
@ -72,7 +73,11 @@ fun ReaderImageViewer(
|
|||
|
||||
val zoomableState = rememberZoomableState(zoomSpec = ZoomSpec(maxZoomFactor = 4f))
|
||||
|
||||
val painter = rememberAsyncImagePainter(model = imageData.imageUrl)
|
||||
val painter = rememberAsyncImagePainter(
|
||||
ImageRequest.Builder(LocalContext.current).addHeader(
|
||||
"Referer", imageData.imageUrl.extractDomain() ?: ""
|
||||
).data(data = imageData.imageUrl).build()
|
||||
)
|
||||
|
||||
LaunchedEffect(painter.intrinsicSize) {
|
||||
zoomableState.setContentLocation(
|
||||
|
@ -153,4 +158,4 @@ fun ReaderImageViewer(
|
|||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue