-
Notifications
You must be signed in to change notification settings - Fork 0
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
🐛 強制リフレッシュ処理を追加 #113
🐛 強制リフレッシュ処理を追加 #113
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
package club.nito.core.datastore | ||
|
||
public sealed interface DataStore | ||
public sealed interface DataStore { | ||
public suspend fun setRefreshed(isRefreshed: Boolean) | ||
public suspend fun isRefreshed(): Boolean | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,9 +6,20 @@ import com.russhwolf.settings.coroutines.SuspendSettings | |
import com.russhwolf.settings.coroutines.toSuspendSettings | ||
import kotlinx.serialization.json.Json | ||
|
||
@OptIn(ExperimentalSettingsApi::class) | ||
public class SettingsDataStore( | ||
private val settings: Settings, | ||
@OptIn(ExperimentalSettingsApi::class) | ||
private val suspendSettings: SuspendSettings = settings.toSuspendSettings(), | ||
private val json: Json, | ||
) : DataStore | ||
) : DataStore { | ||
override suspend fun setRefreshed(isRefreshed: Boolean) { | ||
suspendSettings.putBoolean(REFRESHED_KEY, isRefreshed) | ||
} | ||
|
||
override suspend fun isRefreshed(): Boolean = suspendSettings.getBoolean(REFRESHED_KEY, false) | ||
|
||
public companion object { | ||
private const val REFRESHED_KEY = "refreshed-v0-3-3" | ||
} | ||
} | ||
Comment on lines
+9
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,5 @@ public sealed interface AuthRemoteDataSource { | |
public suspend fun logout() | ||
public suspend fun modifyAuthUser(email: String?, password: String?): UserInfo | ||
public suspend fun authIfNeeded() | ||
public suspend fun refreshCurrentSession() | ||
} | ||
Comment on lines
11
to
15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
authStatus
フローの変換ロジックに例外処理が含まれていません。remoteDataSource.refreshCurrentSession()
の呼び出しに失敗した場合に備えて、エラーハンドリングを追加することを検討してください。また、セッションのリフレッシュが成功した後に新しいAuthStatus
を発行する必要があるかどうかを確認してください。Committable suggestion