-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
See individual commits! Main thing is this adds caching to desktop, so it's not just in-memory anymore.
- Loading branch information
Showing
19 changed files
with
158 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
samples/star/src/androidMain/kotlin/com/slack/circuit/star/data/ContextStarAppDirs.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright (C) 2024 Slack Technologies, LLC | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package com.slack.circuit.star.data | ||
|
||
import android.content.Context | ||
import com.slack.circuit.star.di.AppScope | ||
import com.slack.circuit.star.di.ApplicationContext | ||
import com.squareup.anvil.annotations.ContributesBinding | ||
import com.squareup.anvil.annotations.optional.SingleIn | ||
import javax.inject.Inject | ||
import okio.FileSystem | ||
import okio.Path | ||
import okio.Path.Companion.toOkioPath | ||
|
||
@SingleIn(AppScope::class) | ||
@ContributesBinding(AppScope::class) | ||
class ContextStarAppDirs | ||
@Inject | ||
constructor( | ||
@ApplicationContext private val context: Context, | ||
override val fs: FileSystem, | ||
) : StarAppDirs { | ||
|
||
override val userConfig: Path by lazy { | ||
(context.filesDir.toOkioPath() / "config").also(fs::createDirectories) | ||
} | ||
|
||
override val userData: Path by lazy { | ||
(context.filesDir.toOkioPath() / "data").also(fs::createDirectories) | ||
} | ||
|
||
override val userCache: Path by lazy { context.cacheDir.toOkioPath() } | ||
} |
31 changes: 0 additions & 31 deletions
31
samples/star/src/androidMain/kotlin/com/slack/circuit/star/data/TokenStorageModule.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
samples/star/src/commonMain/kotlin/com/slack/circuit/star/data/StarAppDirs.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (C) 2024 Slack Technologies, LLC | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package com.slack.circuit.star.data | ||
|
||
import okio.FileSystem | ||
import okio.Path | ||
import okio.Path.Companion.toPath | ||
|
||
/** Common interface for access to different directories on the filesystem. */ | ||
interface StarAppDirs { | ||
val fs: FileSystem | ||
val userConfig: Path | ||
val userData: Path | ||
val userCache: Path | ||
} | ||
|
||
class FakeStarAppDirs(override val fs: FileSystem) : StarAppDirs { | ||
override val userConfig: Path = "/userConfig".toPath().also(fs::createDirectories) | ||
override val userData: Path = "/userData".toPath().also(fs::createDirectories) | ||
override val userCache: Path = "/userCache".toPath().also(fs::createDirectories) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
37 changes: 37 additions & 0 deletions
37
samples/star/src/jvmMain/kotlin/com/slack/circuit/star/data/DesktopStarAppDirs.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright (C) 2024 Slack Technologies, LLC | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package com.slack.circuit.star.data | ||
|
||
import com.slack.circuit.star.di.AppScope | ||
import com.squareup.anvil.annotations.ContributesBinding | ||
import com.squareup.anvil.annotations.optional.SingleIn | ||
import javax.inject.Inject | ||
import net.harawata.appdirs.AppDirsFactory | ||
import okio.FileSystem | ||
import okio.Path | ||
import okio.Path.Companion.toPath | ||
|
||
@SingleIn(AppScope::class) | ||
@ContributesBinding(AppScope::class) | ||
class DesktopStarAppDirs @Inject constructor(override val fs: FileSystem) : StarAppDirs { | ||
|
||
private val appDirs = AppDirsFactory.getInstance() | ||
|
||
override val userConfig: Path by lazy { | ||
appDirs.getUserConfigDir(APP_NAME, APP_VERSION, APP_AUTHOR).toPath().also(fs::createDirectories) | ||
} | ||
|
||
override val userData: Path by lazy { | ||
appDirs.getUserDataDir(APP_NAME, APP_VERSION, APP_AUTHOR).toPath().also(fs::createDirectories) | ||
} | ||
|
||
override val userCache: Path by lazy { | ||
appDirs.getUserCacheDir(APP_NAME, APP_VERSION, APP_AUTHOR).toPath().also(fs::createDirectories) | ||
} | ||
|
||
private companion object { | ||
const val APP_NAME = "STAR" | ||
const val APP_VERSION = "1.0.0" | ||
const val APP_AUTHOR = "slackhq" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters