Skip to content

Commit

Permalink
Fix issues with image caching on UWP
Browse files Browse the repository at this point in the history
  • Loading branch information
DRSchlaubi committed Feb 6, 2024
1 parent cd661da commit 145ae9f
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 14 deletions.
5 changes: 0 additions & 5 deletions app/desktop/src/commonMain/kotlin/NativeUtil.kt

This file was deleted.

6 changes: 3 additions & 3 deletions app/shared/src/commonMain/kotlin/ImageLoader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import coil3.request.ImageRequest
import coil3.request.crossfade
import dev.schlaubi.tonbrett.app.api.AppContext
import mu.KotlinLogging
import okio.FileSystem
import okio.Path

private val LOG = KotlinLogging.logger { }

Expand Down Expand Up @@ -67,7 +67,7 @@ fun newImageLoader(appContext: AppContext): ImageLoader = ImageLoader.Builder(ap

expect fun newDiskCache(): DiskCache?

internal fun fileSystemDiskCache(directory: String) =
DiskCache.Builder().directory(FileSystem.SYSTEM_TEMPORARY_DIRECTORY / "image_cache")
internal fun fileSystemDiskCache(directory: Path) =
DiskCache.Builder().directory(directory / "image_cache")
.maxSizeBytes(512L * 1024 * 1024) // 512MB
.build()
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.awt.ComposeWindow
import androidx.compose.ui.window.FrameWindowScope
import androidx.compose.ui.window.WindowScope
import androidx.compose.ui.window.WindowState
import coil3.disk.DiskCache
import okio.Path
import okio.Path.Companion.toPath
Expand Down Expand Up @@ -47,4 +44,4 @@ private fun getBasePath(): Path {
return basePath / "Tonbrett"
}

actual fun newDiskCache(): DiskCache? = fileSystemDiskCache(getBasePath().toString())
actual fun newDiskCache(): DiskCache? = fileSystemDiskCache(getBasePath())
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
@file:JvmName("ImageLoaderMobile")

package dev.schlaubi.tonbrett.app

import coil3.disk.DiskCache
import okio.FileSystem
import kotlin.jvm.JvmName

actual fun newDiskCache(): DiskCache? = fileSystemDiskCache(FileSystem.SYSTEM_TEMPORARY_DIRECTORY.toString())
actual fun newDiskCache(): DiskCache? = fileSystemDiskCache(FileSystem.SYSTEM_TEMPORARY_DIRECTORY)
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {

allprojects {
group = "dev.schlaubi.tonbrett"
version = "1.18.12"
version = "1.18.13"

repositories {
mavenCentral()
Expand Down

0 comments on commit 145ae9f

Please sign in to comment.