Skip to content

Commit 635ef89

Browse files
Merge pull request #11 from taetae98coding/develop
1.8.3
2 parents 7ca1edd + fbc9357 commit 635ef89

26 files changed

Lines changed: 157 additions & 104 deletions

File tree

Diary/Diary.xcodeproj/project.pbxproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@
315315
"$(inherited)",
316316
"@executable_path/Frameworks",
317317
);
318-
MARKETING_VERSION = 1.8.2;
318+
MARKETING_VERSION = 1.8.3;
319319
OTHER_LDFLAGS = "";
320320
PRODUCT_BUNDLE_IDENTIFIER = io.github.taetae98coding.diary.dev;
321321
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -413,7 +413,7 @@
413413
"$(inherited)",
414414
"@executable_path/Frameworks",
415415
);
416-
MARKETING_VERSION = 1.8.2;
416+
MARKETING_VERSION = 1.8.3;
417417
OTHER_LDFLAGS = "";
418418
PRODUCT_BUNDLE_IDENTIFIER = io.github.taetae98coding.diary;
419419
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -518,7 +518,7 @@
518518
"$(inherited)",
519519
"@executable_path/Frameworks",
520520
);
521-
MARKETING_VERSION = 1.8.2;
521+
MARKETING_VERSION = 1.8.3;
522522
OTHER_LDFLAGS = "";
523523
PRODUCT_BUNDLE_IDENTIFIER = io.github.taetae98coding.diary;
524524
PRODUCT_NAME = "$(TARGET_NAME)";

app/android/dependencies/realReleaseRuntimeClasspath.txt

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -34,28 +34,28 @@ androidx.compose.material:material-icons-extended-android:1.7.6
3434
androidx.compose.material:material-icons-extended:1.7.6
3535
androidx.compose.material:material-ripple-android:1.11.0-rc01
3636
androidx.compose.material:material-ripple:1.11.0-rc01
37-
androidx.compose.runtime:runtime-android:1.11.0
38-
androidx.compose.runtime:runtime-annotation-android:1.11.0
39-
androidx.compose.runtime:runtime-annotation:1.11.0
40-
androidx.compose.runtime:runtime-retain-android:1.11.0
41-
androidx.compose.runtime:runtime-retain:1.11.0
42-
androidx.compose.runtime:runtime-saveable-android:1.11.0
43-
androidx.compose.runtime:runtime-saveable:1.11.0
44-
androidx.compose.runtime:runtime:1.11.0
45-
androidx.compose.ui:ui-android:1.11.0
46-
androidx.compose.ui:ui-geometry-android:1.11.0
47-
androidx.compose.ui:ui-geometry:1.11.0
48-
androidx.compose.ui:ui-graphics-android:1.11.0
49-
androidx.compose.ui:ui-graphics:1.11.0
50-
androidx.compose.ui:ui-text-android:1.11.0
51-
androidx.compose.ui:ui-text:1.11.0
52-
androidx.compose.ui:ui-tooling-preview-android:1.11.0
53-
androidx.compose.ui:ui-tooling-preview:1.11.0
54-
androidx.compose.ui:ui-unit-android:1.11.0
55-
androidx.compose.ui:ui-unit:1.11.0
56-
androidx.compose.ui:ui-util-android:1.11.0
57-
androidx.compose.ui:ui-util:1.11.0
58-
androidx.compose.ui:ui:1.11.0
37+
androidx.compose.runtime:runtime-android:1.11.1
38+
androidx.compose.runtime:runtime-annotation-android:1.11.1
39+
androidx.compose.runtime:runtime-annotation:1.11.1
40+
androidx.compose.runtime:runtime-retain-android:1.11.1
41+
androidx.compose.runtime:runtime-retain:1.11.1
42+
androidx.compose.runtime:runtime-saveable-android:1.11.1
43+
androidx.compose.runtime:runtime-saveable:1.11.1
44+
androidx.compose.runtime:runtime:1.11.1
45+
androidx.compose.ui:ui-android:1.11.1
46+
androidx.compose.ui:ui-geometry-android:1.11.1
47+
androidx.compose.ui:ui-geometry:1.11.1
48+
androidx.compose.ui:ui-graphics-android:1.11.1
49+
androidx.compose.ui:ui-graphics:1.11.1
50+
androidx.compose.ui:ui-text-android:1.11.1
51+
androidx.compose.ui:ui-text:1.11.1
52+
androidx.compose.ui:ui-tooling-preview-android:1.11.1
53+
androidx.compose.ui:ui-tooling-preview:1.11.1
54+
androidx.compose.ui:ui-unit-android:1.11.1
55+
androidx.compose.ui:ui-unit:1.11.1
56+
androidx.compose.ui:ui-util-android:1.11.1
57+
androidx.compose.ui:ui-util:1.11.1
58+
androidx.compose.ui:ui:1.11.1
5959
androidx.concurrent:concurrent-futures-ktx:1.1.0
6060
androidx.concurrent:concurrent-futures:1.1.0
6161
androidx.core:core-ktx:1.18.0
@@ -353,15 +353,15 @@ org.jetbrains.compose.material3:material3:1.11.0-alpha07
353353
org.jetbrains.compose.material:material-icons-core:1.7.3
354354
org.jetbrains.compose.material:material-icons-extended:1.7.3
355355
org.jetbrains.compose.material:material-ripple:1.11.0-beta03
356-
org.jetbrains.compose.runtime:runtime-saveable:1.11.0-rc01
357-
org.jetbrains.compose.runtime:runtime:1.11.0-rc01
358-
org.jetbrains.compose.ui:ui-geometry:1.11.0-rc01
359-
org.jetbrains.compose.ui:ui-graphics:1.11.0-rc01
360-
org.jetbrains.compose.ui:ui-text:1.11.0-rc01
361-
org.jetbrains.compose.ui:ui-tooling-preview:1.11.0-rc01
362-
org.jetbrains.compose.ui:ui-unit:1.11.0-rc01
363-
org.jetbrains.compose.ui:ui-util:1.11.0-rc01
364-
org.jetbrains.compose.ui:ui:1.11.0-rc01
356+
org.jetbrains.compose.runtime:runtime-saveable:1.11.0
357+
org.jetbrains.compose.runtime:runtime:1.11.0
358+
org.jetbrains.compose.ui:ui-geometry:1.11.0
359+
org.jetbrains.compose.ui:ui-graphics:1.11.0
360+
org.jetbrains.compose.ui:ui-text:1.11.0
361+
org.jetbrains.compose.ui:ui-tooling-preview:1.11.0
362+
org.jetbrains.compose.ui:ui-unit:1.11.0
363+
org.jetbrains.compose.ui:ui-util:1.11.0
364+
org.jetbrains.compose.ui:ui:1.11.0
365365
org.jetbrains.kotlin:kotlin-stdlib-common:2.3.21
366366
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.0
367367
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.22

build-logic/src/main/kotlin/BuildConfig.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ public data object BuildConfig {
44
internal const val ANDROID_TARGET_SDK = 36
55

66
public const val NAMESPACE: String = "io.github.taetae98coding.diary"
7-
public const val VERSION_NAME: String = "1.8.2"
8-
public const val VERSION_CODE: Int = 11
7+
public const val VERSION_NAME: String = "1.8.3"
8+
public const val VERSION_CODE: Int = 12
99
}

core/model/src/commonMain/kotlin/io/github/taetae98coding/diary/core/model/account/Account.kt

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,21 @@ import kotlin.uuid.Uuid
44

55
public sealed interface Account {
66
public val accountId: Uuid
7+
public val isAuthorized: Boolean
78

89
public data object Guest : Account {
910
override val accountId: Uuid = Uuid.NIL
11+
override val isAuthorized: Boolean = true
1012
}
1113

1214
public data class User(
13-
override val accountId: Uuid,
14-
val email: String,
15-
val profileImage: String?,
16-
) : Account
15+
val accountInfo: AccountInfo,
16+
val accountMetaData: AccountMetaData?,
17+
) : Account {
18+
override val accountId: Uuid
19+
get() = accountInfo.id
20+
21+
override val isAuthorized: Boolean
22+
get() = accountInfo.isAuthorized
23+
}
1724
}

core/model/src/commonMain/kotlin/io/github/taetae98coding/diary/core/model/account/AccountInfo.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ import kotlin.uuid.Uuid
55
public data class AccountInfo(
66
val id: Uuid,
77
val email: String,
8+
val isAuthorized: Boolean,
89
)

core/model/src/commonMain/kotlin/io/github/taetae98coding/diary/core/model/sync/SyncStatus.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ package io.github.taetae98coding.diary.core.model.sync
33
public sealed interface SyncStatus {
44
public data object Idle : SyncStatus
55
public data class Syncing(val type: SyncType) : SyncStatus
6-
public data object Failed : SyncStatus
6+
public data class Failed(val type: SyncType) : SyncStatus
77
}

core/supabase/api/src/commonMain/kotlin/io/github/taetae98coding/diary/core/supabase/api/SupabaseSessionStatus.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ public sealed interface SupabaseSessionStatus {
66
val email: String?,
77
) : SupabaseSessionStatus
88

9-
public data object NotAuthenticated : SupabaseSessionStatus
9+
public data class NotAuthenticated(
10+
val userId: String?,
11+
val email: String?,
12+
) : SupabaseSessionStatus {
13+
public companion object {
14+
public val NotLogin: NotAuthenticated = NotAuthenticated(userId = null, email = null)
15+
}
16+
}
17+
1018
public data object Loading : SupabaseSessionStatus
1119
}

core/supabase/impl/src/commonMain/kotlin/io/github/taetae98coding/diary/core/supabase/impl/SupabaseAuthImpl.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ internal class SupabaseAuthImpl(private val supabase: SupabaseClient) : Supabase
2929
)
3030
}
3131

32-
is SessionStatus.NotAuthenticated -> SupabaseSessionStatus.NotAuthenticated
32+
is SessionStatus.NotAuthenticated -> getSessionStatusFromStorage() ?: SupabaseSessionStatus.NotAuthenticated.NotLogin
3333

3434
is SessionStatus.Initializing -> getSessionStatusFromStorage() ?: SupabaseSessionStatus.Loading
3535

@@ -40,17 +40,17 @@ internal class SupabaseAuthImpl(private val supabase: SupabaseClient) : Supabase
4040
}
4141
}
4242

43-
private suspend fun resolveRefreshFailure(cause: RefreshFailureCause?): SupabaseSessionStatus {
43+
private suspend fun resolveRefreshFailure(cause: RefreshFailureCause?): SupabaseSessionStatus.NotAuthenticated {
4444
return when (cause) {
45-
is RefreshFailureCause.InternalServerError -> SupabaseSessionStatus.NotAuthenticated
46-
else -> getSessionStatusFromStorage() ?: SupabaseSessionStatus.NotAuthenticated
45+
is RefreshFailureCause.InternalServerError -> SupabaseSessionStatus.NotAuthenticated.NotLogin
46+
else -> getSessionStatusFromStorage() ?: SupabaseSessionStatus.NotAuthenticated.NotLogin
4747
}
4848
}
4949

50-
private suspend fun getSessionStatusFromStorage(): SupabaseSessionStatus? {
50+
private suspend fun getSessionStatusFromStorage(): SupabaseSessionStatus.NotAuthenticated? {
5151
return runCatching {
5252
supabase.auth.sessionManager.loadSession().user
53-
?.let { SupabaseSessionStatus.Authenticated(userId = it.id, email = it.email) }
53+
?.let { SupabaseSessionStatus.NotAuthenticated(userId = it.id, email = it.email) }
5454
}.getOrNull()
5555
}
5656

data/account/src/commonMain/kotlin/io/github/taetae98coding/diary/data/account/repository/AccountInfoRepositoryImpl.kt

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,21 @@ internal class AccountInfoRepositoryImpl(
3030
status is SupabaseSessionStatus.Authenticated || status is SupabaseSessionStatus.NotAuthenticated
3131
}.mapLatest { status ->
3232
when (status) {
33-
is SupabaseSessionStatus.Authenticated -> AccountInfo(
34-
id = Uuid.parse(status.userId),
35-
email = requireNotNull(status.email),
36-
)
33+
is SupabaseSessionStatus.Authenticated -> {
34+
AccountInfo(
35+
id = Uuid.parse(status.userId),
36+
email = status.email ?: return@mapLatest null,
37+
isAuthorized = true,
38+
)
39+
}
3740

38-
is SupabaseSessionStatus.NotAuthenticated -> null
41+
is SupabaseSessionStatus.NotAuthenticated -> {
42+
AccountInfo(
43+
id = Uuid.parse(status.userId ?: return@mapLatest null),
44+
email = status.email ?: return@mapLatest null,
45+
isAuthorized = false,
46+
)
47+
}
3948

4049
else -> null
4150
}

data/sync/src/androidMain/kotlin/io/github/taetae98coding/diary/data/sync/AndroidSyncManager.kt

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@file:OptIn(ExperimentalCoroutinesApi::class)
2+
13
package io.github.taetae98coding.diary.data.sync
24

35
import android.content.Context
@@ -13,10 +15,9 @@ import io.github.taetae98coding.diary.core.model.sync.SyncStatus
1315
import io.github.taetae98coding.diary.core.model.sync.SyncType
1416
import io.github.taetae98coding.diary.domain.account.usecase.GetAccountUseCase
1517
import io.github.taetae98coding.diary.domain.sync.manager.SyncManager
18+
import kotlin.time.Clock
1619
import kotlin.uuid.Uuid
17-
import kotlinx.coroutines.flow.Flow
18-
import kotlinx.coroutines.flow.MutableStateFlow
19-
import kotlinx.coroutines.flow.combine
20+
import kotlinx.coroutines.ExperimentalCoroutinesApi
2021
import kotlinx.coroutines.flow.flatMapLatest
2122
import kotlinx.coroutines.flow.flowOf
2223
import kotlinx.coroutines.flow.mapLatest
@@ -25,28 +26,32 @@ import org.koin.core.annotation.Single
2526
@Single
2627
internal class AndroidSyncManager(
2728
private val context: Context,
29+
private val clock: Clock,
2830
getAccountUseCase: GetAccountUseCase,
2931
) : SyncManager {
30-
private val syncTypeFlow = MutableStateFlow(SyncType.Background)
31-
override val syncStatus: Flow<SyncStatus> = combine(
32-
syncTypeFlow,
33-
getAccountUseCase(),
34-
) { syncType, accountResult ->
32+
override val syncStatus = getAccountUseCase().flatMapLatest { accountResult ->
3533
accountResult.fold(
3634
onSuccess = { account ->
3735
WorkManager.getInstance(context).getWorkInfosForUniqueWorkFlow("SYNC_${account.accountId}")
3836
.mapLatest { workInfos ->
39-
when {
40-
workInfos.any { it.state == WorkInfo.State.RUNNING || it.state == WorkInfo.State.ENQUEUED } -> SyncStatus.Syncing(syncType)
41-
workInfos.any { it.state == WorkInfo.State.FAILED } -> SyncStatus.Failed
37+
val last = workInfos.maxByOrNull { info ->
38+
info.tags.find { it.startsWith("timestamp") }
39+
?.removePrefix("timestamp")
40+
?.toLongOrNull()
41+
?: 0L
42+
} ?: return@mapLatest SyncStatus.Idle
43+
44+
val syncType = SyncType.entries.find { last.tags.contains(it.name) } ?: SyncType.Background
45+
46+
when (last.state) {
47+
WorkInfo.State.RUNNING, WorkInfo.State.ENQUEUED -> SyncStatus.Syncing(syncType)
48+
WorkInfo.State.FAILED -> SyncStatus.Failed(syncType)
4249
else -> SyncStatus.Idle
4350
}
4451
}
4552
},
4653
onFailure = { flowOf(SyncStatus.Idle) },
4754
)
48-
}.flatMapLatest {
49-
it
5055
}
5156

5257
override fun requestSync(
@@ -61,9 +66,10 @@ internal class AndroidSyncManager(
6166
.setConstraints(constraints)
6267
.setInputData(workDataOf(SyncWorker.ACCOUNT_ID to accountId.toString()))
6368
.setExpedited(OutOfQuotaPolicy.RUN_AS_NON_EXPEDITED_WORK_REQUEST)
69+
.addTag("timestamp${clock.now().toEpochMilliseconds()}")
70+
.addTag(type.name)
6471
.build()
6572

66-
syncTypeFlow.value = type
6773
WorkManager.getInstance(context).enqueueUniqueWork(
6874
uniqueWorkName = "SYNC_$accountId",
6975
existingWorkPolicy = ExistingWorkPolicy.REPLACE,

0 commit comments

Comments
 (0)